{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lists_Part_1 - as[X|L where X is a list item and L is a...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Lists York University Department of Computer Science and Engineering York University- CSE 3401- V. Movahedi 1 05_Lists
Background image of page 1

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

View Full Document Right Arrow Icon
Overview Definition and representation of Lists in Prolog Dot functor Examples of recursive definition of predicates islist, member, delete append, multiple, prefix, suffix, sublist [ref.: Clocksin- Chap.3 and Nilsson- Chap. 7] [also Prof. Gunnar Gotshalks ’ slides] York University- CSE 3401 2 05_Lists
Background image of page 2
Lists A list: is an ordered sequence of elements that can have any length. List notation in Prolog: [a, b, c, d, ...] Either an empty list [] or it has a head X and a tail L represented
Background image of page 3

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

View Full Document Right Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: as [X|L] where X is a list item and L is a list. • The dot: – is a functor for representing lists with two arguments, the head and the tail of a list – A list of one element [a] is [a| ] implemented in Prolog as .(a, ) – [a, b] is .(a, .(b, )) • Note [a, b, c] is not the same as [a, [b,c]] York University- CSE 3401 3 05_Lists Lists (cont.) . a . b . c York University- CSE 3401 4 [a, b, c] is .(a, .(b, .(c, ))) 05_Lists Lists (cont.) . a . . b . C York University- CSE 3401 5 [a, [b, c]] is .(a, L) where L is [[b,c]] having [b,c] as its head and as tail 05_Lists...
View Full Document

{[ snackBarMessage ]}