Re: call to idiomatic loop works as stand alone but not when wrapped in my function

2011-04-16 Thread Phlex
n 15/04/2011 01:21, Avram wrote: Yes, I am missing a way to turn the [& filenames] into something like "name1" "name2" … You also missed Joost's answer =) Use apply for this : user> (+ 1 2 3) 6 user> (apply + (list 1 2 3)) 6 So in your case : (apply read-files-into-memory fnames) hth, Sa

Re: call to idiomatic loop works as stand alone but not when wrapped in my function

2011-04-15 Thread Avram
This makes perfect sense. I reached for this strategy initially but got lost along the way trying to consider how to enable N inputs via a -main function. I'm all set now. Many thanks, Avram On Apr 15, 11:11 am, Alan wrote: > You never "need" & when you are defining your own functions. It's > e

Re: call to idiomatic loop works as stand alone but not when wrapped in my function

2011-04-15 Thread Alan
You never "need" & when you are defining your own functions. It's equivalent to declaring that your function takes one argument, a vector, and then always wrapping up in a vector whatever args you want to use. On Apr 15, 11:05 am, Avram wrote: > Thank-you, I think that works for me!  I do need th

Re: call to idiomatic loop works as stand alone but not when wrapped in my function

2011-04-15 Thread Avram
Thank-you, I think that works for me! I do need the & to be able to take in a variable number of arguments, but it looks like I can call "vec" to convert this to a vector, then call the read-files-into- memory function that now will take a single argument. Such an elegant language but difficult to

Re: call to idiomatic loop works as stand alone but not when wrapped in my function

2011-04-15 Thread Alan
I would do it by making read-files-into-memory take a single argument, a list of filenames, rather than N arguments, each of which is a filename. Just drop the & in the function's definition and you should be done. On Apr 14, 4:21 pm, Avram wrote: > Yes, I am missing a way to turn the [& filename

Re: call to idiomatic loop works as stand alone but not when wrapped in my function

2011-04-14 Thread Avram
Yes, I am missing a way to turn the [& filenames] into something like "name1" "name2" … How might this be done? (I am not certain what "type" this would be, a stringified version of each item in the sequence, not a sequence itself! ) (defn read-files-into-memory [ & filenames ] (print filena

Re: call to idiomatic loop works as stand alone but not when wrapped in my function

2011-04-14 Thread Joost
(defn read-files-into-memory [ & filenames ] (print filenames) (map #(read-json-filename %1) filenames)) The [& filenames] argument spec turns all the arguments given into a sequence. You're not passing the filenames as separate arguments, but as a vector, so you either have to change that: