Can the head of a list in prolog consist of multiple elements? -


for example if have list [1, 2| 3], head 1, 2 , tail 3? or head still 1 , tail 2, 3?

note: [1, 2| 3] not list; [1, 2 | [3]] is.

short answer: there one element in head, [1, 2| [3]] syntactical sugar [1 | [2 | [3]]], list [1, 2, 3].

prolog's lists lisp lists: consist out of 2 possible values: empty list [], , "cons" [h|t] h *head, , t tail.

most prolog interpreters allow syntactical sugar [e1, e2, e3] , [e1, e2, e3 | t]. make more convient list processing.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -