(index ("anaphora" 0) ("aif" 222) ("nif" 497) ("awhen" 778) ("nwhen" 1136) ("acond" 1502) ("ncond" 1929) ("awhile" 2362) ("nwhile" 2883) ("aand" 3410) ("nand" 3692) ("alambda" 3994) ("nlambda" 4305) ("define-anaphor" 4625) ("define-properties" 5122) ("list-recurser" 5597) ("alist-recurser" 5900) ("tree-recurser" 6301) ("atree-recurser" 6685))
(def (sig (procedure "(anaphora sym ..)" (id anaphora))) (p "Documentation procedure. Called without argument it returns the list of exported symbols, with one of those symbols as argument it returns its documentation."))
(def (sig (syntax "(aif test consequent alternative ..)" (id aif))) (p "Anaphoric version of if.") (p "Binds the result of test to the symbol it, which can than be used in the consequent or the mandatory anternative.") (highlight scheme "(aif (memv 3 '(1 2 3 4 5)) it #f)"))
(def (sig (syntax "(nif name test consequent alternative ..)" (id nif))) (p "Named version of if.") (p "Binds the result of test to the symbol name, which can than be used in the consequent or the mandatory anternative.") (highlight scheme "(nif it (memv 3 '(1 2 3 4 5)) it #f)"))
(def (sig (syntax "(awhen test xpr . xprs)" (id awhen))) (p "Anaphoric version of when, i.e. the one-armed if, which allows multiple expressions to be evaluated, if test succeeds. As with aif, the result of test is stored in the variable it, which can be refered in xpr ...") (highlight scheme "(awhen (memv 3 '(1 2 3 4 5))\n  (print it)\n  (reverse it))"))
(def (sig (syntax "(nwhen name test xpr . xprs)" (id nwhen))) (p "Named version of when, i.e. the one-armed if, which allows multiple expressions to be evaluated, if test succeeds. As with nif, the result of test is stored in the variable name, which can be refered in the body.") (highlight scheme "(nwhen it (memv 3 '(1 2 3 4 5))\n  (print it)\n  (reverse it))"))
(def (sig (syntax "(acond ((test xpr ...) ... (else ypr ...) ..))" (id acond))) (p "Anaphoric version of cond.") (p "The result of each test is stored in the variable it, which can be used in the corresponding expressions xpr ...") (highlight scheme "(acond\n\t((memv 6 '(1 2 3 4 5)) it)\n\t((memv 3 '(1 2 3 4 5)) it)\n\t(else it))") (p "Note, that the ordinary cond macro does something similar with the literal symbol =>."))
(def (sig (syntax "(ncond name ((test xpr ...) ... (else ypr ...) ..))" (id ncond))) (p "Named version of cond.") (p "The result of each test is stored in the variable name, which can be used in the corresponding expressions xpr ...") (highlight scheme "(ncond it\n\t((memv 6 '(1 2 3 4 5)) it)\n\t((memv 3 '(1 2 3 4 5)) it)\n\t(else it))") (p "Note, that the ordinary cond macro does something similar with the literal symbol =>."))
(def (sig (syntax "(awhile test xpr . xprs)" (id awhile))) (p "Anaphoric version of while.") (p "The body xpr . xprs is evaluated as often, as the test is true. As usual, the result of this test, which often is the result of a poll operation, is named it and can be referenced in the body.") (highlight scheme "(let ((lst '(1 2 3 4 5 #f)) (res '()))\n\t(awhile (car lst)\n\t\t(set! res (cons (car lst) res))\n\t\t(set! lst (cdr lst)))\n\tres)") (p "Of course, this is not the preferred programming style in Scheme ..."))
(def (sig (syntax "(nwhile name test xpr . xprs)" (id nwhile))) (p "Named version of while.") (p "The body xpr . xprs is evaluated as often, as the test is true. As usual, the result of this test, which often is the result of a poll operation, is named name and can be referenced in the body.") (highlight scheme "(let ((lst '(1 2 3 4 5 #f)) (res '()))\n\t(nwhile it (car lst)\n\t\t(set! res (cons (car lst) res))\n\t\t(set! lst (cdr lst)))\n\tres)") (p "Of course, this is not the preferred programming style in Scheme ..."))
(def (sig (syntax "(aand arg ...)" (id aand))) (p "Anaphoric version of and.") (p "When sequentially evaluating the arguments arg ..., the anaphor it will be bound to the value of the previous argument.") (highlight scheme "(let ((lst '(1 2 3)))\n  (aand lst (cdr it) (cdr it)))"))
(def (sig (syntax "(nand name arg ...)" (id nand))) (p "Named version of and.") (p "When sequentially evaluating the arguments arg ..., the identifier name will be bound to the value of the previous argument.") (highlight scheme "(let ((lst '(1 2 3 4)))\n  (nand it lst (cdr it) (cdr it) (car it)))"))
(def (sig (syntax "(alambda args xpr . xprs)" (id alambda))) (p "Anaphoric version of lambda.") (p "The resulting procedure is bound to the anaphor self. This way, anonymous functions can be recursive as well.") (highlight scheme "(map (alambda (n) (if (zero? n) 1 (* n (self (- n 1)))))\n     '(1 2 3 4 5))"))
(def (sig (syntax "(nlambda name args xpr . xprs)" (id nlambda))) (p "Named version of lambda.") (p "The resulting procedure is bound to the identifier name. This way, anonymous functions can be recursive as well.") (highlight scheme "(map (nlambda self (n) (if (zero? n) 1 (* n (self (- n 1)))))\n     '(1 2 3 4 5))"))
(def (sig (syntax "(define-anaphor name from rule)" (id define-anaphor))) (p "Hygienic macro which writes an anaphoric macro with implicit it, name, from another procedure or macro, from, with rule either #:cascade or #:first Note, that most of the macros above could have been created by means of define-anaphor.") (highlight scheme "(define-anaphor alist list #:cascade)\n(alist 1 (+ it 2) (* it 3)) ; -> '(1 3 9)\n(define-anaphor awhen when #:first)\n(awhen (* 1 2 3 4 5) (* 2 it)) ; -> 240"))
(def (sig (syntax "(define-properties name ...)" (id define-properties))) (p "Abstracting away get and put!. Defines for each name two macros, name and name!, the first being an accessor to the property name, the second the corresponding mutator.") (highlight scheme "(define-properties color weight)\n(color! 'foo 'red)\n(color 'foo) ; -> 'red\n(weight! 'foo 5)\n(weight 'foo) ;-> 5\n(color! 'foo 'blue)\n(color 'foo) ; -> 'blue\n(weight! 'foo 50)\n(weight 'foo) ; -> 50"))
(def (sig (procedure "(list-recurser recurser base)" (id list-recurser))) (p "generates a procedure which traverses on the cdrs of its only list argument.") (highlight scheme "(define (lsome? ok?)\n  (list-recurser (lambda (lst th) (or (ok? (car lst)) (th))) #f))\n((lsome? odd?) '(2 4 5 6)) ; -> #t"))
(def (sig (syntax "(alist-recurser recur-xpr base-xpr)" (id alist-recurser))) (p "anaphoric macro with internal symbols it, representing the current list, and go-on, representing traversal along cdrs. The result is a procedure, which recurs on its only list argument.") (highlight scheme "(define (alsome? ok?)\n  (alist-recurser (or (ok? (car it)) (go-on)) #f))\n((alsome? odd?) '(2 4 6)) ; -> #f"))
(def (sig (procedure "(tree-recurser recurser base)" (id tree-recurser))) (p "generates a procedure which traverses on the cars and the cdrs of its only tree argument.") (highlight scheme "(define tcopy\n  (tree-recurser (lambda (tree left right)\n                   (cons (left) (or (right) '())))\n                 identity))\n(tcopy '(1 (2 (3 4) 5) 6)) ; -> '(1 (2 (3 4) 5) 6) "))
(def (sig (syntax "(atree-recurser recur-xpr base-xpr)" (id atree-recurser))) (p "anaphoric macro with internal symbols it, representing the current tree, go-left and go-right, representing traversal along cars and cdrs respectively. The result is a procedure, which recurs on its only list argument.") (highlight scheme "(define atcopy\n  (atree-recurser (cons (go-left) (or (go-right) '())) it))\n(atcopy '(1 (2 3 (4)) 5)) ; -> '(1 (2 3 (4)) 5)"))
