diff options
author | Marvin Borner | 2023-06-26 00:32:28 +0200 |
---|---|---|
committer | Marvin Borner | 2023-06-26 00:32:28 +0200 |
commit | 79cf34e878da5118bdfc25a02d78f4e21574600d (patch) | |
tree | 3f148058bb9f516e5b897c40effed58a4159a1bc /std/List.bruijn | |
parent | ad0762d1288f78bb3201a37814c95821e1a7957a (diff) |
Added eval/apply functions
Diffstat (limited to 'std/List.bruijn')
-rw-r--r-- | std/List.bruijn | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/std/List.bruijn b/std/List.bruijn index 12e85c8..f35ec6f 100644 --- a/std/List.bruijn +++ b/std/List.bruijn @@ -56,6 +56,20 @@ length z [[[rec]]] (+0) ⧗ (List a) → Number :test (∀((+1) : {}(+2))) ((+2)) :test (∀empty) ((+0)) +# applies each element of a list to a function +# TODO: Fix variadicity in signature +apply z [[[rec]]] ⧗ (a → b) → (List a) → b + rec ∅?0 case-end case-app + case-app 2 (1 ^0) ~0 + case-end 1 + +:test (apply …+… ((+1) : {}(+2))) ((+3)) + +# applies each element of the tail to the head +eval [apply ^0 ~0] ⧗ (Pair (a → b) (List a)) → b + +:test (eval (…+… : ((+1) : {}(+2)))) ((+3)) + # returns the element at index in list index z [[[rec]]] ⧗ (List a) → Number → a rec ∅?0 case-end case-index |