pounce-lang / js-core

Core elements of a Pounce (pounce-lang) interpreter, parser, preprocessor written in TypeScript. Pounce types are being developed (a preprocess type checker is in beta)
https://pounce-lang-show-case.netlify.app/
6 stars 0 forks source link

pattern naming for crouch and pounce #15

Closed nmorse closed 2 years ago

nmorse commented 2 years ago

instead of having to stack shuffle like this


[1 0] # accumulator is a pair [acc index] the index is used to either multiply or add 
[swap uncons uncons drop [acc i] [acc [i 2 % 0 ==] [*] [+] ifte 1 i +] pounce [] cons cons] 
reduce```

if `crouch` and `pounce` could name elements in lists patterns and dis-assemble them, then less stack shuffling would be needed, like this
```[6 3 8 4 5 7 2 9 1] 
[1 0] # accumulator is a pair [acc index] the index is used to either multiply or add 
[[ele [acc i]] [ele acc [i 2 % 0 ==] [*] [+] ifte 1 i +] pounce cons-2 ] 
reduce```

``` [ [] cons cons ] [cons-2] compose ```