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

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

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « petitparser/lib/src/lisp/parser.dart ('k') | petitparser/lib/src/reflection/iterable.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 part of lisp;
2
3 /**
4 * The standard library.
5 */
6 class Standard {
7
8 /** Imports the standard library into the [environment]. */
9 static Environment import(Environment environment) {
10 evalString(lispParser, environment, _standardLibrary);
11 return environment;
12 }
13
14 /** A simple standard library, should be moved to external file. */
15 static String _standardLibrary = """
16 ; null functions
17 (define null '())
18 (define (null? x) (= '() x))
19
20 ; booleans
21 (define true (and))
22 (define false (or))
23
24 ; list functions
25 (define (length list)
26 (if (null? list)
27 0
28 (+ 1 (length (cdr list)))))
29
30 (define (append list1 list2)
31 (if (null? list1)
32 list2
33 (cons (car list1) (append (cdr list1) list2))))
34
35 (define (list-head list index)
36 (if (= index 0)
37 (car list)
38 (list-head
39 (cdr list)
40 (- index 1))))
41
42 (define (list-tail list index)
43 (if (= index 0)
44 (cdr list)
45 (list-tail
46 (cdr list)
47 (- index 1))))
48
49 (define (for-each list proc)
50 (while (not (null? list))
51 (proc (car list))
52 (set! list (cdr list))))
53
54 (define (map list proc)
55 (if (null? list)
56 '()
57 (cons (proc (car list))
58 (map (cdr list) proc))))
59
60 (define (inject list value proc)
61 (if (null? list)
62 value
63 (inject
64 (cdr list)
65 (proc value (car list))
66 proc)))
67 """;
68 }
OLDNEW
« no previous file with comments | « petitparser/lib/src/lisp/parser.dart ('k') | petitparser/lib/src/reflection/iterable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698