next up previous contents
Next: Specifying the syntactic Up: CHAPTER.4: PROCEDURES IN Previous: DEFINING PROCEDURES IN

Using "define <name> = ... enddefine"

There is an alternative syntax that is often useful when existing procedures are being used to create new procedures. We have already used it in defining closures, above:

    define
        then <name of procedure>
        then =
        then an expression evaluating to a procedure
        then
    enddefine;
Examples: A procedure formed by concatenating two other procedures

    define pr_sqrt = sqrt <> pr enddefine;

    pr_sqrt(16);
    4.0
A procedure formed by partial application

    define list_of_doubles =
        maplist(%procedure (x); x + x endprocedure%)
    enddefine;

    list_of_doubles([1 2 3 4]) =>
    ** [2 4 6 8]
A procedure that's actually a property

    define father_of =
        newproperty([[tom joe][mary joe][harry dick]],100,false,true)
    enddefine;

    father_of("mary") =>
    ** joe
    father_of("joe") =>
    ** <false>


Aaron Sloman
Fri Jan 2 03:17:44 GMT 1998