Sfoglia il codice sorgente

Rename head/tail to first/rest

Trying to avoid conflict with the <head> tag
master
Dylan Baker 5 anni fa
parent
commit
a0ac2606ec
2 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  1. 2
    2
      src/core.js
  2. 2
    2
      test/coreTest.js

+ 2
- 2
src/core.js Vedi File

@@ -14,6 +14,6 @@ module.exports = {
14 14
   list: (...args) => new AST.List({ elements: args }),
15 15
   length: xs => new AST.Number({ value: xs.elements.length }),
16 16
   cons: (x, xs) => new AST.List({ elements: [x, ...xs.elements] }),
17
-  head: xs => xs.elements[0],
18
-  tail: xs => new AST.List({ elements: xs.elements.slice(1) }),
17
+  first: xs => xs.elements[0],
18
+  rest: xs => new AST.List({ elements: xs.elements.slice(1) }),
19 19
 }

+ 2
- 2
test/coreTest.js Vedi File

@@ -35,8 +35,8 @@ test('map', t => {
35 35
         (if (= (length xs) 0)
36 36
           (list)
37 37
           (cons
38
-            (f (head xs))
39
-            (my-map f (tail xs))))))
38
+            (f (first xs))
39
+            (my-map f (rest xs))))))
40 40
 
41 41
     (my-map (lambda (x) (+ x 1)) (list 1 2 3))
42 42
   `)

Loading…
Annulla
Salva