1
0
mirror of https://github.com/janet-lang/janet synced 2025-09-02 19:08:04 +00:00

Rename to janet

This commit is contained in:
Calvin Rose
2018-09-05 22:18:42 -04:00
parent 285f2d7ea9
commit c8ef2a0d88
69 changed files with 6199 additions and 6259 deletions

14
examples/primes.janet Normal file
View File

@@ -0,0 +1,14 @@
# Return an array of primes. This is a trivial and extremely naive algorithm.
(defn primes
"Returns a list of prime numbers less than n."
[n]
(def list @[])
(loop [i :range [2 n]]
(var isprime? true)
(def len (length list))
(loop [j :range [0 len]]
(def trial (get list j))
(if (zero? (% i trial)) (:= isprime? false)))
(if isprime? (array.push list i)))
list)