A single `for` will suffice:
(let [nums (range 1 4)]
(for [x nums y nums]
(* x y)))
If you wanted to build a map from pairs of elements of the input
collection to the matching values of your distance function, you could
do something like
(into {} (for [x xs y xs] [[x y] (distance x y)]))
You might want to replace [x y] with (hash-set x y) in the likely case
of distance being commutative.
Note also that if you're building the table to avoid recalculating the
distances, you might be better served by memoization; see (doc
memoize) at the REPL.
Sincerely,
Michał
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en