{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lists_Part_1

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

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

Lists York University Department of Computer Science and Engineering York University- CSE 3401- V. Movahedi 1 05_Lists

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

View Full Document
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
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

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.

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 ]}