diff options
Diffstat (limited to 'std')
-rw-r--r-- | std/List.bruijn | 4 | ||||
-rw-r--r-- | std/Math.bruijn | 1 | ||||
-rw-r--r-- | std/Number.bruijn | 2 | ||||
-rw-r--r-- | std/Number/Binary.bruijn | 1 | ||||
-rw-r--r-- | std/Number/Ternary.bruijn | 3 | ||||
-rw-r--r-- | std/Tree/Rose.bruijn | 4 |
6 files changed, 9 insertions, 6 deletions
diff --git a/std/List.bruijn b/std/List.bruijn index 39aecf8..bb8bed3 100644 --- a/std/List.bruijn +++ b/std/List.bruijn @@ -1,7 +1,6 @@ # MIT License, Copyright (c) 2022 Marvin Borner # Lists in Church/Boehm-Berarducci encoding using pairs # implementations are generally lazy (except when they're broken) -# TODO: Replace fold/map/etc. with faster LC native logic :import std/Combinator . :import std/Pair P @@ -85,6 +84,9 @@ eval-r z [[rec]] :test (~!(inc : (inc : {}(+1)))) ((+3)) +# returns the element at unary index in list +index-unary [[P.fst (0 P.snd 1)]] ⧗ (List a) → Unary → a + # returns the element at index in list index z [[[rec]]] ⧗ (List a) → Number → a rec 0 [[[case-index]]] case-end diff --git a/std/Math.bruijn b/std/Math.bruijn index 07a9a9b..1737572 100644 --- a/std/Math.bruijn +++ b/std/Math.bruijn @@ -1,4 +1,5 @@ # MIT License, Copyright (c) 2022 Marvin Borner +# experimental functions, sometimes list-based :input std/Number diff --git a/std/Number.bruijn b/std/Number.bruijn index ffc2591..f74b7d4 100644 --- a/std/Number.bruijn +++ b/std/Number.bruijn @@ -1,6 +1,6 @@ # MIT License, Copyright (c) 2023 Marvin Borner # this is just a reference to the ternary implementation -# read the readme for the reasoning of using balanced ternary by default +# read the wiki for the reasoning of using balanced ternary by default :import std/List . diff --git a/std/Number/Binary.bruijn b/std/Number/Binary.bruijn index ea837e3..28a3f7f 100644 --- a/std/Number/Binary.bruijn +++ b/std/Number/Binary.bruijn @@ -1,4 +1,5 @@ # MIT License, Copyright (c) 2023 Marvin Borner +# binary implementation of T.Æ. Mogensen (see refs in README) # TODO: Use abstract representation for logic instead of listifying :import std/Combinator . diff --git a/std/Number/Ternary.bruijn b/std/Number/Ternary.bruijn index e9b402c..e1b3893 100644 --- a/std/Number/Ternary.bruijn +++ b/std/Number/Ternary.bruijn @@ -1,7 +1,6 @@ # MIT License, Copyright (c) 2022 Marvin Borner -# This file defines the most basic mathematical operations +# ternary implementation of T.Æ. Mogensen and Douglas W. Jones (see refs in README) # → refer to std/Math for more advanced functions -# Heavily inspired by the works of T.Æ. Mogensen and Douglas W. Jones (see refs in README) :import std/Box B :import std/Combinator . diff --git a/std/Tree/Rose.bruijn b/std/Tree/Rose.bruijn index 90abeec..1b1e319 100644 --- a/std/Tree/Rose.bruijn +++ b/std/Tree/Rose.bruijn @@ -34,7 +34,7 @@ empty? [L.empty? ~0] ⧗ (RoseTree a) → Boolean ∅?‣ empty? -:test (∅?({ 'a' : (({:}'b') : L.empty) })) (false) +:test (∅?({ 'a' : ({:}'b' : L.empty) })) (false) :test (∅?({:}'a')) (true) # applies a function to leaf and the leafs of all branches @@ -43,7 +43,7 @@ map z [[[rec]]] ⧗ (a → b) → (RoseTree a) → (RoseTree b) …<$>… map -:test (map ^‣ ({ "woo" : ({:}"oof" : (({ "aah" : (({:}"huh" : L.empty)) }) : L.empty)) })) ({ 'w' : ({:}'o' : (({ 'a' : ({:}'h' : L.empty) }) : L.empty)) }) +:test (map ^‣ ({ "woo" : ({:}"oof" : (({ "aah" : ({:}"huh" : L.empty) }) : L.empty)) })) ({ 'w' : ({:}'o' : (({ 'a' : ({:}'h' : L.empty) }) : L.empty)) }) # maps a function returning list of trees and concatenates concat-map L.concat ∘∘ map ⧗ ((RoseTree a) → (List (RoseTree b))) → (List (RoseTree a)) → (List (RoseTree b)) |