Skip to content

Commit 707d8c2

Browse files
committed
feat: adding macros -> and partial
1 parent 094a676 commit 707d8c2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
### Added
55
- Lazy evaluation with `lazy:eval`
66
- Math functions to manipulate complex numbers (addition, substraction, multiplication, division, conjugate, module)
7+
- Macros `->` to pipe transformations on data and `partial` to create partial functions easily
78

89
### Changed
910
- enhanced `math:fibo` function to hide the accumulator parameters

Macros.ark

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
!{-> (arg fn1 ...fn) {
2+
!{if (> (len fn) 0)
3+
(-> (fn1 arg) ...fn)
4+
(fn1 arg)
5+
}
6+
}}
7+
8+
# internal, do not use
9+
!{__suffix-dup (sym x) {
10+
!{if (> x 1)
11+
(__suffix-dup sym (- x 1))
12+
}
13+
(symcat sym x)
14+
}}
15+
16+
!{partial (func ...defargs) {
17+
!{bloc (__suffix-dup a (- (argcount func) (len defargs)))}
18+
(fun (bloc) (func ...defargs bloc))
19+
!{undef bloc}
20+
}}

0 commit comments

Comments
 (0)