Fork me on GitHub
#beginners
<
2021-06-20
>
vinurs03:06:27

is there any way to generate dynamic args for for

(for [a1 [1 2 3]
      a2 [1 2 3]]
  ;;do sth
  )
to
(for [a1 [1 2 3]
      a2 [1 2 3]
      ...
      an [1 2 3]
      ]
  ;;do sth
  )

andy.fingerhut03:06:41

You could write a macro that generates a for expression with a different number of bindings determined at compile time, but instead you might want to consider a function that generates the cross product of its input sequences.

andy.fingerhut03:06:03

For example, the cartesian-product function in the math.combinatorics library mentioned in the library's README here: https://github.com/clojure/math.combinatorics

vinurs03:06:17

@U0CMVHBL2 thanks for your help

hiredman23:06:15

for can be built by using map and mapcat

hiredman23:06:42

(for [x xs] e) => (map (fn [x] e) es)

hiredman23:06:41

(for [x xs y ys] e) => (mapcat (fn [x] (map (fn [y] e) ys)) xs)

quan xing08:06:34

• I want to learn Clojure, where is a good tutorial

practicalli-johnny09:06:15

There are lots of free resources (some commercial ones too) https://clojure.org/community/resources If you like learning fromvideo, take a look at https://practical.li/ (there are free books too)

sandeep16:06:53

101 videos on clojure is enough for getting job ?

practicalli-johnny20:06:01

Creating all those videos helped me get my current job, I cannot guarantee if it would get anyone else a job :)

practicalli-johnny20:06:56

If a person can do the first 60 or so challenges on http://4clojure.com and come up with some nice answers for the Clojure track on http://Exercism.io, that would certainly help give a very good grounding in the core Clojure language. Then it just depends on what other esoteric requirements a company as part of their hiring process

👍 3
sova-soars-the-sora16:06:50

Living Clojure is a great book -- your local library might have some clojure books or you could request your local library to get some ^.^

quan xing10:06:44

Thanks everyone