Skip to content

Commit 470673d

Browse files
committed
adding different recursion sample, added fragments from book's license
1 parent abf6070 commit 470673d

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

InspirationLicense.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
------------------------------------------------------------------------------
2+
Some of the test code and some fragments of other code come from
3+
"Writing An Interpreter In Go", are originally licensed under the
4+
MIT License (MIT), which follows.
5+
------------------------------------------------------------------------------
6+
7+
Copyright (c) 2016-2017 Thorsten Ball
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,14 @@ Status: done up to and including 4.5: ie functional int, string and boolean expr
8383
- [x] add >= and <= comparaison operators
8484

8585
- [x] add comments support (line)
86+
- [ ] add /* */ style
8687

8788
- [ ] line numbers for errors (for file mode)
8889

8990
- [x] use `func` instead of `fn` for functions
91+
92+
- [x] figure out how to get syntax highlighting (go style closest - done thx to viulisti -> .gitattributes)
93+
94+
- [ ] assignment to maps and arrays
95+
96+
- [ ] for loop

apply2.gr

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Another example (see sample.gr)
2+
// Variant with accumulation of result down the stack
3+
4+
a = [ 1, 3, 5, 7]
5+
6+
apply = func(f, a) {
7+
// helper function
8+
h = func(f, a, result) {
9+
if (len(a) == 0) {
10+
return result
11+
}
12+
return h(f, rest(a), result + f(first(a)))
13+
}
14+
h(f, a, [])
15+
}
16+
17+
apply(func(x) { 2 * x }, a)
18+
19+
// ^^^ [2, 6, 10, 14]

0 commit comments

Comments
 (0)