~plan/plunder

99829ca5dff39684027325a68f72a0f40479a196 — Sol 4 months ago cfb72d7
sire: foldrRev, listFromRowRev
2 files changed, 26 insertions(+), 15 deletions(-)

M sire/sire_05_row.sire
M sire/sire_07_dat.sire
M sire/sire_05_row.sire => sire/sire_05_row.sire +11 -2
@@ 84,7 84,7 @@
:| sire_01_fan [isApp isLaw lawName lawArgs lawBody]
:| sire_01_fan [id const apply supply]
:| sire_01_fan [isOne]
:| sire_02_bit [if ifNot and or not]
:| sire_02_bit [if ifz ifNot and or not]
:| sire_03_nat [dec sub add]
:| sire_04_cmp [eql isZero lth gte]



@@ 211,6 211,13 @@
| seq acc
| go acc (inc i) rem

= (foldrRev f z row)
^ _ (_Len row)
? (go rem)
| ifz rem z
@ i (dec rem)
| f (get row i) (go i)


;;; Higher-Level Jets ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



@@ 271,6 278,8 @@
=?= (foldl FOO {z} (0 1))      | FOO {z} 1
=?= (foldl FOO {z} (0 2 1))    | FOO (FOO {z} 1) 2

=?= (foldrRev FOO {z} (v3 1 2 3)) | FOO 3 | FOO 2 | FOO 1 {z}

=?= (v3 1 2 3) | weld (v0) (v3 1 2 3)
=?= (v3 1 2 3) | weld (v1 1) (v2 2 3)
=?= (v3 1 2 3) | weld (v2 1 2) (v1 3)


@@ 384,7 393,7 @@
^-^ cow isCow cowSize
^-^ isRow
^-^ weld
^-^ gen foldr foldl
^-^ gen foldr foldl foldrRev
^-^ fst snd thr
^-^ map foreach
^-^ rev

M sire/sire_07_dat.sire => sire/sire_07_dat.sire +15 -13
@@ 361,17 361,18 @@
& (x xs)
| CONS f-x listMap-f-xs

= (listLen l)      | listFoldr (x acc & inc acc) 0 l
= (listSum l)      | listFoldr add 0 l
= (listFromRow v)  | foldr CONS NIL v
= (listAnd v)      | listFoldr and TRUE v
= (listOr v)       | listFoldr or 0 v
= (listAll f v)    | listAnd listMap-f-v
= (listAny f v)    | listOr listMap-f-v
= (listHas e xs)   | listAny eql-e xs
= (listEnumFrom n) | CONS n (listEnumFrom inc-n)
= (listRepeat n)   | CONS n listRepeat-n
= (listAllEql xs)  | listCase xs TRUE (x xs)&(listAll (eql x) xs)
= (listLen l)        | listFoldr (x acc & inc acc) 0 l
= (listSum l)        | listFoldr add 0 l
= (listFromRow v)    | foldr CONS NIL v
= (listFromRowRev v) | foldrRev CONS NIL v
= (listAnd v)        | listFoldr and TRUE v
= (listOr v)         | listFoldr or 0 v
= (listAll f v)      | listAnd listMap-f-v
= (listAny f v)      | listOr listMap-f-v
= (listHas e xs)     | listAny eql-e xs
= (listEnumFrom n)   | CONS n (listEnumFrom inc-n)
= (listRepeat n)     | CONS n listRepeat-n
= (listAllEql xs)    | listCase xs TRUE (x xs)&(listAll (eql x) xs)

= (listWeld a b)
| listCase a b


@@ 972,8 973,9 @@ F=found
^-^
^-^ listFoldl listFoldl1
^-^ listFoldr
^-^ listLen listToRow sizedListToRow sizedListToRowRev
^-^ listToRowRev listFromRow
^-^ listLen sizedListToRow sizedListToRowRev
^-^ listToRow listFromRow
^-^ listToRowRev listFromRowRev
^-^ listAnd listOr listSum listAll listAllEql listAny
^-^ listHas listEnumFrom listWeld listCat listCatMap listTake listDrop
^-^ listTakeWhile listDropWhile