EDITED because question is about same program.
I'm trying to take the top fifty items in the first vector and write them to the topfifty variable, to return to use elsewhere.
"gets the开发者_运维问答 closest 50 locations in the file fName and writes them out by sending a function to the agent"
[fName]
(let [sorted (sort-by sortFn (makeStructs fName))
topFifty ;TODO take the top 50 from sorted
]
How exactly do I do this in clojure? I'm new to the language and have never used lisp. I'd rather not use a for loop as that is not exactly functional-ish.
To answer the new question (the question that my other answer was in response to has been replaced): (take 50 sorted)
will return the first 50 elements of sorted
.
You probably want something like (apply struct storeinfo vals)
, where vals
is the result of your split. This unpacks all of the values in vals
into a call to (struct storeinfo ...)
, which creates a storeinfo
from initial values in the same order as its definition.
精彩评论