L7_List

# L7_List - What are Lists The next Data Structure that we...

This preview shows pages 1–16. Sign up to view the full content.

What are Lists The next Data Structure that we learn is called a list . [4, 8, 5, 6, 7, 3] Head Tail Operations: There are many operations on lists. The basic ones are Obtaining the head of a list. Obtaining the tail of a list. Page 1 of 47

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Head and Tail of a List [ , , , , , ] Head Tail Head : Tail : [ , , , , ] Head is an element. Tail is a list. Page 2 of 47
Head and Tail of a List ['a', 'd', 'e', 'b', 's', 'a', 'e'] Head : 'a' Tail : ['d', 'e', 'b', 's', 'a', 'e'] Head is an element. Tail is a list. Page 3 of 47

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Head and Tail of a List [4, 5, 8, 9, 7, 6, 3] Head : 4 Tail : [5, 8, 9, 7, 6, 3] Head is an element. Tail is a list. Page 4 of 47
Head and Tail of a List [4] Head : 4 Tail : [] Head is an element. Tail is a list. Page 5 of 47

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Head and Tail of the Empty List [] Head : - Tail : - Empty List has no head. Empty List has no tail. ( In fact, Empty List is usually seen as a constant. ) Page 6 of 47
Head and Tail of a List [[1,2], [3,4,8,9], [5,6,7]] Head : [1,2] Tail : [[3,4,8,9], [5,6,7]] Head is an element. Tail is a list. Page 7 of 47

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Head and Tail of a List ['a', [3,4,8,9], , 23] Head : 'a' Tail : [[3,4,8,9], , 23] Head is an element. Tail is a list. Page 8 of 47
Head and Tail of a List [[], [2,3], [1]] Head : [] Tail : [[2,3], [1]] Head is an element. Tail is a list. Page 9 of 47

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Head and Tail of a List [[]] Head : [] Tail : [] Head is an element. Tail is a list. Page 10 of 47
List Operations The list construction operation constructs a new list from a head and a list. Cons(4, [5, 8, 9, 7, 6, 3]) [4, 5, 8, 9, 7, 6, 3] Page 11 of 47

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
List Operations The list construction operation constructs a new list from a head and a list. Cons(4, [8]) [4, 8] Page 12 of 47
List Operations The list construction operation constructs a new list from a head and a list. Cons(9, []) [9] Page 13 of 47

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
List Operations The list construction operation constructs a new list from a head and a list. Cons(7, Cons(8, Cons(9, []) )) Cons(7, Cons(8, [9] ) ) Cons(7, [8, 9] ) [7, 8, 9] Page 14 of 47
The list construction operation constructs a new list from a head and a list. Cons([1,2,3], [4, 5, 6])

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 47

L7_List - What are Lists The next Data Structure that we...

This preview shows document pages 1 - 16. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online