aboutsummaryrefslogtreecommitdiffhomepage
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/List.bruijn7
-rw-r--r--std/String.bruijn8
2 files changed, 12 insertions, 3 deletions
diff --git a/std/List.bruijn b/std/List.bruijn
index 891dc7c..7673456 100644
--- a/std/List.bruijn
+++ b/std/List.bruijn
@@ -18,7 +18,6 @@ empty? [0 [[[false]]] true]
<>?( empty?
:test (<>?empty) (true)
-:test (<>?(cons (+2) empty)) (false)
# prepends an element to a list
cons P.pair
@@ -26,6 +25,7 @@ cons P.pair
(:) cons
:test ((+1) : ((+2) : empty)) (P.pair (+1) (P.pair (+2) empty))
+:test (<>?((+2) : empty)) (false)
# returns the head of a list or empty
head P.fst
@@ -203,6 +203,7 @@ concat foldr append empty
# TODO: ?
# :test (concat ((((+1) : ((+2) : empty)) : ((+3) : ((+4) : empty))) : empty)) ((+1) : ((+2) : ((+3) : ((+4) : empty))))
+
:test (concat ("a" : ("b" : empty))) ("ab")
# maps a function returning list of list and concatenates
@@ -336,6 +337,6 @@ iterate z [[[rec]]]
rec 0 : (2 1 (1 0))
:test (take (+5) (iterate inc (+0))) (((+0) : ((+1) : ((+2) : ((+3) : ((+4) : empty))))))
-:test (take (+2) (iterate dec (+5))) (((+5) : ((+4) : empty)))
-:test (take (+5) (iterate i (+4))) (repeat (+5) (+4))
+:test (take (+2) (iterate sdec (+5))) (((+5) : ((+4) : empty)))
+:test (take (+5) (iterate i (+4))) (take (+5) (repeat (+4)))
:test (take (+0) (iterate inc (+0))) (empty)
diff --git a/std/String.bruijn b/std/String.bruijn
index 4c872a8..20634c7 100644
--- a/std/String.bruijn
+++ b/std/String.bruijn
@@ -12,6 +12,14 @@ eq? eq? B.eq?
:test ("ab" =? "ab") (true)
:test ("ab" =? "aa") (false)
+# returns true if character is part of a string
+in? in? B.eq?
+
+∈ \in?
+
+:test (∈ 'b' "ab") (true)
+:test (∈ 'c' "ab") (false)
+
# splits string by newline character
lines Z [[rec]]
rec <>?(~broken) (^broken : empty) (^broken : (1 ~(~broken)))