Basic cell, list and symbol manipulation


Functions

muse_cell fn_define (muse_env *env, void *context, muse_cell args)
 (define symbol value).
muse_cell fn_set_M (muse_env *env, void *context, muse_cell args)
 (set! symbol value).
muse_cell fn_setf_M (muse_env *env, void *context, muse_cell args)
 (setf! cell value).
muse_cell fn_setr_M (muse_env *env, void *context, muse_cell args)
 (setr! cell value).
muse_cell fn_first (muse_env *env, void *context, muse_cell args)
 (first list).
muse_cell fn_rest (muse_env *env, void *context, muse_cell args)
 (rest list).
muse_cell fn_next (muse_env *env, void *context, muse_cell args)
muse_cell fn_nth (muse_env *env, void *context, muse_cell args)
 (nth n list).
muse_cell fn_take (muse_env *env, void *context, muse_cell args)
 (take N ls).
muse_cell fn_drop (muse_env *env, void *context, muse_cell args)
 (drop N list).
muse_cell fn_dup (muse_env *env, void *context, muse_cell args)
 (dup arg).
muse_cell fn_list (muse_env *env, void *context, muse_cell args)
 (list a1 a2 .
muse_cell fn_length (muse_env *env, void *context, muse_cell args)
 (length l).
muse_cell fn_append_M (muse_env *env, void *context, muse_cell args)
 (append! list1 list2 -so-on- listN).

Function Documentation

muse_cell fn_define ( muse_env env,
void *  context,
muse_cell  args 
)

(define symbol value).

Sets the current value of the symbol. symbol is not evaluated, value is evaluated.

Examples -

This example simply evaluates value and assigns it as the value of the given symbol.

 (define symbol value)

The second example provides additional documentation about the symbol being defined, using an arbitrary property structure identified by the keyword doc at the head of the documentation block, followed by an association list of the documentation writer's own choosing. Typical documentation property words include usage for a brief description of the usage syntax, descr for a more elaborate description of the object being created, and brief for a brief textual description of the purpose of the object.

 (define symbol 
   (doc (usage "(symbol param1 param2)")
        (descr "Computes symbol")
        (param1 "The first value")
        (param2 "The second value"))
   (fn (p1 p2) (+ p1 p2)))
The defined function takes two arguments and returns their sum. Pretty lame function, but serves to illustrate.

If you want the documentation block to be ignored by the reader, then you should call muse_init_env with the MUSE_DISCARD_DOC parameter set to MUSE_TRUE.

muse_cell fn_set_M ( muse_env env,
void *  context,
muse_cell  args 
)

(set! symbol value).

Inside a function body or let or case block, it changes the value of the given locally declared symbol. Cannot in general be used to set the value of a global symbol, unless that symbol is, up to this point, undefined.

muse_cell fn_setf_M ( muse_env env,
void *  context,
muse_cell  args 
)

(setf! cell value).

Sets the head of the given cons cell to the given value.

muse_cell fn_setr_M ( muse_env env,
void *  context,
muse_cell  args 
)

(setr! cell value).

Sets the tail of the given cons cell to the given value.

muse_cell fn_first ( muse_env env,
void *  context,
muse_cell  args 
)

(first list).

Gets the head of the list, which is the first element.

muse_cell fn_rest ( muse_env env,
void *  context,
muse_cell  args 
)

(rest list).

Gets the tail of the list. This is intended to be read as "rest of the list".

muse_cell fn_next ( muse_env env,
void *  context,
muse_cell  args 
)

muse_cell fn_nth ( muse_env env,
void *  context,
muse_cell  args 
)

(nth n list).

Gets the n-th element of a list.

n is zero based. Returns item at index n in the list. Could be thought of as "skip n, then return head".

muse_cell fn_take ( muse_env env,
void *  context,
muse_cell  args 
)

(take N ls).

Returns a new list consisting of a maximum of N items of the given list "ls".

muse_cell fn_drop ( muse_env env,
void *  context,
muse_cell  args 
)

(drop N list).

Literally does that - drops N items from the given list and returns a list of the remaining items. Examples -

Does not create a new list like take does.

muse_cell fn_dup ( muse_env env,
void *  context,
muse_cell  args 
)

(dup arg).

Creates a structural duplicate of the given argument.

muse_cell fn_list ( muse_env env,
void *  context,
muse_cell  args 
)

(list a1 a2 .

.. ) Returns a list of the given items - the list of items is a copy, though the items refer to the same objects.

muse_cell fn_length ( muse_env env,
void *  context,
muse_cell  args 
)

(length l).

Returns length of the proper list. Undefined behaviour on improper lists.

muse_cell fn_append_M ( muse_env env,
void *  context,
muse_cell  args 
)

(append! list1 list2 -so-on- listN).

Modifies the tail of list1 to point to list2, tail of list2 to list3 etc. All except listN are modified.

For example -

 (define a (list 1 2 3 4 5))
 (define b (list 10 20 30 40 50))
 (append! a b)
 (print a)
will print
 (1 2 3 4 5 10 20 30 40 50)


Generated on Mon Sep 25 23:12:50 2006 for muSE by  doxygen 1.4.7