1
0
mirror of https://github.com/janet-lang/janet synced 2025-12-06 08:38:07 +00:00

Move pretty printer into boot.dst

This commit is contained in:
Calvin Rose
2018-03-14 19:08:00 -04:00
parent c0ac44a650
commit 8ec29d9326
6 changed files with 52 additions and 53 deletions

14
examples/primes.dst 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 [])
(for [i 2 n]
(var isprime? true)
(def len (length list))
(for [j 0 len]
(def trial (get list j))
(if (zero? (% i trial)) (varset! isprime? false)))
(if isprime? (array-push list i)))
list)