Skip to content

Commit fe92ac3

Browse files
committed
Initial commit of aList.js
1 parent a2161c8 commit fe92ac3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Ch4/aList.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// function arrayToList takes an array and outputs a list.
2+
// function prepend creates new list element and prepends it
3+
// function nth takes a list and a number and returns the nth element.
4+
// nth(rest, n-1)
5+
// list is {value, rest}, value is int and rest is another list element
6+
7+
function arrayToList(input) {
8+
9+
}
10+
11+
function listToArray(list) {
12+
13+
}
14+
15+
function prepend(element, list) {
16+
17+
}
18+
19+
function nth(list, n) {
20+
return n == 0 ? list.value : nth(list.rest, n-1);
21+
}

0 commit comments

Comments
 (0)