mirror of
https://github.com/janet-lang/janet
synced 2025-10-30 07:03:02 +00:00
Fix compiler optimization for if.
Add pattern matching library.
This commit is contained in:
@@ -60,7 +60,7 @@
|
||||
(defmacro def-
|
||||
"Define a private value that will not be exported."
|
||||
[name & more]
|
||||
~(def name :private ,;more))
|
||||
~(def ,name :private ,;more))
|
||||
|
||||
(defn defglobal
|
||||
"Dynamically create a global def."
|
||||
@@ -614,6 +614,16 @@
|
||||
(array/push res item)))
|
||||
res)
|
||||
|
||||
(defn count
|
||||
"Count the number of items in ind for which (pred item)
|
||||
is true."
|
||||
[pred ind]
|
||||
(var counter 0)
|
||||
(loop [item :in ind]
|
||||
(if (pred item)
|
||||
(++ counter)))
|
||||
counter)
|
||||
|
||||
(defn keep
|
||||
"Given a predicate, take only elements from an array or tuple for
|
||||
which (pred element) is truthy. Returns a new array of truthy predicate results."
|
||||
|
||||
Reference in New Issue
Block a user