1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-26 00:10:27 +00:00

Update lib files.

This commit is contained in:
Calvin Rose 2018-10-14 23:08:06 -04:00
parent ba82290bae
commit dde6218bff
2 changed files with 5 additions and 3 deletions

View File

@ -38,4 +38,4 @@
(loop [[name color] :in (pairs colormap)] (loop [[name color] :in (pairs colormap)]
(defglobal (string.slice name 1) (defglobal (string.slice name 1)
(fn color-wrapper [& pieces] (fn color-wrapper [& pieces]
(string "\e[" color "m" (apply1 string pieces) "\e[0m")))) (string "\e[" color "m" (apply string pieces) "\e[0m"))))

View File

@ -4,10 +4,11 @@
# that must be called (realizing it), and the memoized. # that must be called (realizing it), and the memoized.
# Use with (import "./path/to/this/file" :prefix "seq.") # Use with (import "./path/to/this/file" :prefix "seq.")
(defmacro delay [& forms] (defmacro delay
"Lazily evaluate a series of expressions. Returns a function that "Lazily evaluate a series of expressions. Returns a function that
returns the result of the last expression. Will only evaluate the returns the result of the last expression. Will only evaluate the
body once, and then memoizes the result." body once, and then memoizes the result."
[& forms]
(def $state (gensym)) (def $state (gensym))
(def $loaded (gensym)) (def $loaded (gensym))
(tuple 'do (tuple 'do
@ -70,8 +71,9 @@
[s] [s]
(when (s) (realize (tail s)))) (when (s) (realize (tail s))))
(defn realize-map [f s] (defn realize-map
"Evaluate f on each member of the sequence. Forces evaluation." "Evaluate f on each member of the sequence. Forces evaluation."
[f s]
(when (s) (f (head s)) (realize-map f (tail s)))) (when (s) (f (head s)) (realize-map f (tail s))))
(defn drop (defn drop