Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: packages/petitparser/lib/src/lisp/standard.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 part of petitparser.lisp;
2
3 /// The standard library.
4 class Standard {
5
6 /// Imports the standard library into the [environment].
7 static Environment import(Environment environment) {
8 evalString(lispParser, environment, _standardLibrary);
9 return environment;
10 }
11
12 /// A simple standard library, should be moved to external file.
13 static String _standardLibrary = """
14 ; null functions
15 (define null '())
16 (define (null? x) (= '() x))
17
18 ; booleans
19 (define true (and))
20 (define false (or))
21
22 ; list functions
23 (define (length list)
24 (if (null? list)
25 0
26 (+ 1 (length (cdr list)))))
27
28 (define (append list1 list2)
29 (if (null? list1)
30 list2
31 (cons (car list1) (append (cdr list1) list2))))
32
33 (define (list-head list index)
34 (if (= index 0)
35 (car list)
36 (list-head
37 (cdr list)
38 (- index 1))))
39
40 (define (list-tail list index)
41 (if (= index 0)
42 (cdr list)
43 (list-tail
44 (cdr list)
45 (- index 1))))
46
47 (define (for-each list proc)
48 (while (not (null? list))
49 (proc (car list))
50 (set! list (cdr list))))
51
52 (define (map list proc)
53 (if (null? list)
54 '()
55 (cons (proc (car list))
56 (map (cdr list) proc))))
57
58 (define (inject list value proc)
59 (if (null? list)
60 value
61 (inject
62 (cdr list)
63 (proc value (car list))
64 proc)))
65 """;
66 }
OLDNEW
« no previous file with comments | « packages/petitparser/lib/src/lisp/parser.dart ('k') | packages/petitparser/lib/src/petitparser/actions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698