Logiweb(TM)

7.3.1 Pair, head, and tail

Prev Up Next Page 176 of 800 Search internet


The eager pair x :: y [x :: y] forms the pair of x and y. The pairing construct x :: y is eager in the sense that it forces both x and y to be evaluated. Furthermore, x :: y inspects x and y to see if they are exceptions. Logiweb also has lazy pairs.

The constructs x head [x head] and x tail [x tail] return the first and second component, respectively, of a pair. Some examples read:

( 2 :: 3 ) head == 2

( ( 1 :: 2 ) :: ( 3 :: 4 ) ) tail head == 3

As mentioned, the eager pair checks its arguments for being exceptions:

2 :: exception == exception

The head and tail constructs return their argument if the argument is not a pair:

true head == true

2 tail == 2

Prev Up Next Page 176 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05