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
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
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
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
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
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
(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:
Dear list,
I have working code for 2 inputs, but I am trying to write an
idiomatic version, where the result is that a function named "read-
files-into-memory" takes a variable number of file names and parses
the json. My code works well until I try to wrap my stand alone call
to map into my "re