diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2024-03-05 18:19:27 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2024-03-05 18:19:27 +0900 |
| commit | 49960d8950d001a372a0abde670a66ee60026957 (patch) | |
| tree | adad1d5fe428bf0bea151f71ed114223fc246bca /sample/map.in | |
| parent | 0cf73da9ad035089c66d21021a656e4606796c47 (diff) | |
| download | inpla-49960d8950d001a372a0abde670a66ee60026957.tar.gz inpla-49960d8950d001a372a0abde670a66ee60026957.zip | |
v0.12.0
Diffstat (limited to 'sample/map.in')
| -rw-r--r-- | sample/map.in | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/sample/map.in b/sample/map.in deleted file mode 100644 index c96daae..0000000 --- a/sample/map.in +++ /dev/null @@ -1,49 +0,0 @@ -// Map operation - -// target function -inc(r)><(int i) => r~(i+1); -subPair(r)><(int m, int n) => r~(m-n); - - -// ----------- main (with the built-in Map and `%' notation) ----------- -Map(r, %inc) ~ [1,2,3]; -r; // r ->[2,3,4] - -Map(rr, %subPair) ~ [(10,2), (30,13)]; -rr; // r4 ->[8,17] - - - - -// ----------- main (without the built-in Map) ----------- -// map -map(result, f) >< [] => result~[], Eraser~f; -map(result, f) >< x:xs => Dup(f1,f2)~f, - result~w:ws, - f1 ~ (w, x), map(ws, f2)~xs; - - -// --- map application without the `%' notation --- -map(r1, (a, inc(a))) ~ [10,11,12]; -r1; // r1 ->[11,12,13] - -map(r2, (a, subPair(a))) ~ [(10,2), (30,13)]; -r2; // r2 ->[8,17] - - -// --- map application with the `%' notation --- -map(r3, %inc) ~ [1,2,3]; -r3; // r3 ->[2,3,4] - -map(r4, %subPair) ~ [(10,2), (30,13)]; -r4; // r4 ->[8,17] - - -// --- map application with `<<' abbriviation also -// --- It seems the simplest to read. -r5 << map(%inc, [100,200,300]); -r5; // r5 ->[101,201,301] - -r6 << map(%subPair, [(10,2), (30,13)]); -r6; // r6 ->[8,17] - |
