Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HyLang : Howto simplest for loop in hy?

Tags:

hy

I wanna get Hy!

How, In Hylang, do I do the simple Python loop:

for i in range(5):
    print(i)
like image 875
dagmarPrime Avatar asked Oct 21 '25 04:10

dagmarPrime


1 Answers

The tutorial provides this example:

(for [x [1 2 3]]
  (print x))         ; => 1 2 3

Changing the variable name, and using range in place of a list, we get:

(for [i (range 5)]
  (print i))
like image 174
Kodiologist Avatar answered Oct 27 '25 06:10

Kodiologist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!