reasoning behind nth and take-nth inconsistent parameter pos.

2014-01-03 Thread Alex Miller
Generally collection functions like conj, assoc, nth, get take the collection as the first arg and return a collection of the same type. The majority of the functions in the core lib are sequence functions working at a higher abstraction level - they take a seqable thing, call seq on it, and r

Re: Read Microsoft Word .doc files in Clojure

2014-01-03 Thread Brendan Younger
I've used the Java code in TextExtractor http://stackoverflow.com/questions/10250617/java-apache-poi-can-i-get-clean-text-from-ms-word-doc-files with good success in Clojure projects. Either throw it in as Java source or convert to Clojure code. You'll probably want the tika-parsers jar ins

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Timothy Washington
Ok, got it. It was an oversight on my part. From a config file, I was pulling in *myns/myfn*. But this is just a symbol. I needed to resolve it, and deref the var that it pointed to. So now the below works. Tricky, but I should have caught it earlier. (apply @(resolve *afn*) params) Thanks guy

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Timothy Washington
Yes, good point. I tried apply, but the result from that is always *nil*(where there should be a value). You're right that it should work (we wouldn't use eval in that scenario), but it doesn't. I tried putting params in a seq a list and a vector, but no dice. I'm still playing around with it. T

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Cedric Greevey
Yeah, he probably could. But maybe he has a good reason for avoiding it that we're not aware of. Though I'm not sure what that could be. On Fri, Jan 3, 2014 at 8:11 PM, Jason Wolfe wrote: > > > > On Fri, Jan 3, 2014 at 4:43 PM, Timothy Washington wrote: > >> The crux of the problem is that the

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Jason Wolfe
On Fri, Jan 3, 2014 at 4:43 PM, Timothy Washington wrote: > The crux of the problem is that the size of *params* can be variable. > Only at runtime, does the code match the loaded *afn*, with the passed in > *params*. So I basically just need to break out the *~@params* into > individuated input a

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Cedric Greevey
Amend what I said: your params would need to be something like `(... system-atom ...), or `(... a-namespace/system-atom ...), or `(... (:foo @system-atoms) ...). Then (eval `(~afn ~@params)) will splice that in and the resulting code will look up the appropriate Var (and then the appropriate map ke

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Cedric Greevey
Your best bet is to move your "system atom" out to a top-level def, like so: (def system-atom (atom '({}))) Then just use (eval `(~afn system-atom)) later on, from places where the system-atom Var is visible (same ns, or :use'd), or use (eval `(~afn x/system-atom)) to qualify the name. The syntax

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Timothy Washington
The crux of the problem is that the size of *params* can be variable. Only at runtime, does the code match the loaded *afn*, with the passed in *params*. So I basically just need to break out the *~@params* into individuated input arguments. The only other way I can think to do that, without using

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Jason Wolfe
Glad to help. I admittedly haven't taken the time to understand what's going on in your code, but whenever I see `eval` I feel compelled to ask: are you sure you need it? With that out of the way, here's a trick I've used to work around related errors: https://groups.google.com/d/msg/cloj

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Timothy Washington
Oh, that was just for demonstration purposes. Those vals are actually getting set in a *let* (see here ). Tim Washington Interruptsoftware.com On Fri, Jan 3, 2

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Timothy Baldridge
Using a def inside a defn really shouldn't be done. Perhaps move the params to a let outside of the s/defn? Or change the def to a let? Timothy Baldridge On Fri, Jan 3, 2014 at 4:18 PM, Timothy Washington wrote: > Hey Jason, > > You were exactly right (which is pretty impressive, being that you

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Timothy Washington
Hey Jason, You were exactly right (which is pretty impressive, being that you've never seen my code). In my (s/defn ..) form, there was an error that was failing silently. (s/defn [one two] ... *#_(def params (atom '({}) ))* (def params '({})) (try (eval `(~afn ~@params)) (catch Exce

Re: ANN: data.fressian, read and write Fressian from Clojure

2014-01-03 Thread Henrik Eneroth
Thanks for this! I watched your talk about this on the conj, and this is really cool stuff. Are there any plans for a ClojureScript version of Fressian? On Thursday, November 14, 2013 5:51:41 PM UTC+1, stuart@gmail.com wrote: > > data.fressian [1] is a Clojure-language wrapper for the refer

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Jason Wolfe
Thanks for the report. Schema fns inside of go blocks seem to work fine for me. It seems likely that you're seeing an exception inside the go block, which is swallowed by default: user> (clojure.core.async/go (println "A")) # A user> (clojure.core.async/go (throw (RuntimeException.)) (printl

Re: Sorting Nested Vectors and filter out some

2014-01-03 Thread john walker
You can do something like this. https://gist.github.com/johnwalker/8243534 On Friday, January 3, 2014 12:37:07 PM UTC-5, Jeff Angle wrote: > > Hi guys! this has made me pull quite a load of hair new to clojure.. > > have a nested vector say [[salt 0 0 %deviation 0&0] [sugar 5 10 > %deviatio

Sorting Nested Vectors and filter out some

2014-01-03 Thread Jeff Angle
Hi guys! this has made me pull quite a load of hair new to clojure.. have a nested vector say [[salt 0 0 %deviation 0&0] [sugar 5 10 %deviation 5$10] [milk 1 2 %deviation 1&2 ] [bread] ...] where % deviation is the actual figure of evaluting the deviation between e.g 5 and 10 for sugar,

Fwd: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Timothy Washington
Forwarding... -- Forwarded message -- From: Timothy Washington Date: Fri, Jan 3, 2014 at 1:17 PM Subject: Re: Core.async, Rules for passing clojure vals to go block To: Shaun Gilchrist I'm using Prismatic's Schema in my code base. Now, it looks like defining some functions with

Re: Introducing PigPen: Map-Reduce for Clojure

2014-01-03 Thread Matt Bossenbroek
I would recommend the Pig setup guide here: http://pig.apache.org/docs/r0.11.0/start.html Then you can run it like this: $ pig -x local -f my-script.pig That said, you really only have to install Pig if you want to run it on a cluster. To run/test/develop queries locally, you can use the dump

Re: reasoning behind nth and take-nth inconsistent parameter pos.

2014-01-03 Thread Jozef Wagner
Hi, nth takes collection and returns item of that collection. In such cases, collection comes first. nth follows the semantics of first, second, get, ... take-nth takes collection and returns other collection. In such cases, collection comes last. take-nth follows the semantics of take, map, filt

reasoning behind nth and take-nth inconsistent parameter pos.

2014-01-03 Thread John Kida
(take-nth i coll) (nth coll i) or (nth coll i not-found) Why is one using the index as the first parameter and the other uses index as its second parameter..? Is there any good articles out there for clojure idioms that may explain some of these things? -- -- You received this message be

How to indent clojure code in Emacs

2014-01-03 Thread Stefan Kamphausen
Hi, FWIW, I prefer M-C-q with the cursor on the opening paren of a form. Cheers, Stefan -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderate

Re: Introducing PigPen: Map-Reduce for Clojure

2014-01-03 Thread Mark Engelberg
This is exciting! Not knowing anything about Pig, is there a walkthrough somewhere that demonstrates how to set up the kind of environment and install the pig tools necessary to run the pig scripts generated by PigPen? Thanks, Mark -- -- You received this message because you are subscribed to

http-kit 2.1.16: bug fixes, new features

2014-01-03 Thread Shen, Feng
Hi, [http-kit "2.1.16"] Change log: https://github.com/http-kit/http-kit/blob/master/history.md 2.1.16 (2014/1/3) HTTP Client: follow 301, 302, 303, 307, 308 properly (thanks paulbutcher) 2.1.15 (2014/1/1) HTTP client:

Re: How to indent clojure code in Emacs

2014-01-03 Thread dennis zhuang
use the 'indent-region' function.You can define a function to indent the whole buffer: (defun indent-buffer () "Indent whole buffer" (interactive) (indent-region (point-min) (point-max)) (message "format successfully")) Then bind the function to a key, i bound it to F7 for me: (global-s

Re: How to indent clojure code in Emacs

2014-01-03 Thread tao
C-x h selects the entire buffer. C-M-\ reindents the selected region. http://stackoverflow.com/questions/11423566/how-do-i-intelligently-re-indent-clojure-in-emacs sorry, I have found the answer. -- tao Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Friday, January 3, 2014 at 5

How to indent clojure code in Emacs

2014-01-03 Thread tao
https://github.com/clojure-emacs/clojure-mode I have installed this plugin, but I don’t know how to indent clojure code, when I already selected a region. In Vim, I can do this using “=“, just a simple key stroke. This a problem when I copy some clojure code from other place, not typed in. I