OLD | NEW |
1 part of lisp; | 1 part of petitparser.lisp; |
2 | 2 |
3 /** | 3 /// The standard library. |
4 * The standard library. | |
5 */ | |
6 class Standard { | 4 class Standard { |
7 | 5 |
8 /** Imports the standard library into the [environment]. */ | 6 /// Imports the standard library into the [environment]. |
9 static Environment import(Environment environment) { | 7 static Environment import(Environment environment) { |
10 evalString(lispParser, environment, _standardLibrary); | 8 evalString(lispParser, environment, _standardLibrary); |
11 return environment; | 9 return environment; |
12 } | 10 } |
13 | 11 |
14 /** A simple standard library, should be moved to external file. */ | 12 /// A simple standard library, should be moved to external file. |
15 static String _standardLibrary = """ | 13 static String _standardLibrary = """ |
16 ; null functions | 14 ; null functions |
17 (define null '()) | 15 (define null '()) |
18 (define (null? x) (= '() x)) | 16 (define (null? x) (= '() x)) |
19 | 17 |
20 ; booleans | 18 ; booleans |
21 (define true (and)) | 19 (define true (and)) |
22 (define false (or)) | 20 (define false (or)) |
23 | 21 |
24 ; list functions | 22 ; list functions |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 57 |
60 (define (inject list value proc) | 58 (define (inject list value proc) |
61 (if (null? list) | 59 (if (null? list) |
62 value | 60 value |
63 (inject | 61 (inject |
64 (cdr list) | 62 (cdr list) |
65 (proc value (car list)) | 63 (proc value (car list)) |
66 proc))) | 64 proc))) |
67 """; | 65 """; |
68 } | 66 } |
OLD | NEW |