Go to the first, previous, next, last section, table of contents.


Lists

MUF does not attempt to be Lisp, but it does provide basic support for Lisp-style Lists -- binary trees built from cons cells. Lisp lists are not terribly efficient in time and space, but they are unmatched in flexibility: If you are doing something like recursively rewriting expressions in place (perhaps in a compiler or while doing a little symbolic algebra), they can turn dismal drudgery to delight.

This isn't the place to explain programming with Lists, so I'll just give some samples of what is available. Much of it is implemented in muq/pkg/100-C-lists.t and as usual you should see the MUF reference manual for further documentation.

root:
"a" "b" cons
root: #<cons>
car
root: "a"
pop
root:
[ "a" "b" "c" "d" ]
root: #<cons>
dup car , "\n" , cdr
a
root: #<cons>
dup car , "\n" , cdr
b
root: #<cons>
dup car , "\n" , cdr
c
root: #<cons>
dup car , "\n" , cdr
d
root: nil
pop
root:
[ [ "a" "b" "c" ] |   :: car ;   maplist   --> _l
root:
_l first   _l second   _l third
root: "a" "b" "c"
pop pop pop
root:
'd' [ 'a' 'b' 'c' ] member?
root: nil
pop
root:
'b' [ 'a' 'b' 'c' ] member? car
root: 'b'
pop
root:
[ 'a' 'b' ] [ 'c' 'd' ] nconc --> _l
root:
_l first  _l second  _l third  _l fourth
root: 'a' 'b' 'c' 'd'
pop pop pop pop
root:
[ [ 'your 'house ] [ 'your 'spouse ] ] --> _l
root:
'my 'your _l nsubst printList

root: "[ [ 'my 'house ] [ 'my 'spouse ] ]"


Go to the first, previous, next, last section, table of contents.