(index ("ck" 0) ("ck" 0) ("ck" 0) ("ck-wrapper" 1127) ("c-quote" 2943) ("c-quasiquote" 3342) ("c-eval" 4268) ("c-call" 4532) ("c-apply" 4827) ("c-compose" 5220) ("c-rcompose" 6095) ("c-flip" 6376) ("c-branch" 6560) ("c-identity" 6963) ("c-constantly" 7198) ("c-make-rules" 7417) ("c-make-next" 9450) ("c-not" 10950) ("c-true" 11136) ("c-false" 11598) ("c-if" 11854) ("c-if*" 12718) ("c-or" 13377) ("c-or*" 13762) ("c-and" 14105) ("c-and*" 14527) ("c-null?" 14869) ("c-pair?" 15077) ("c-not-pair?" 15288) ("c-vector?" 15446) ("c-boolean?" 15707) ("c-sym-eq?" 15933) ("c-sym-equal?" 16689) ("c-compare?" 17247) ("c-cons" 18718) ("c-cons*" 19067) ("c-xcons" 19546) ("c-list" 19828) ("c-car" 20081) ("c-cdr" 20320) ("c-first" 20561) ("c-second" 20561) ("c-third" 20561) ("c-fourth" 20561) ("c-fifth" 20561) ("c-sixth" 20561) ("c-seventh" 20561) ("c-eighth" 20561) ("c-ninth" 20561) ("c-tenth" 20561) ("c-last" 21504) ("c-last-pair" 21830) ("c-drop1" 22160) ("c-drop2" 22160) ("c-drop3" 22160) ("c-drop4" 22160) ("c-drop5" 22160) ("c-take1" 22937) ("c-take2" 22937) ("c-take3" 22937) ("c-take4" 22937) ("c-take5" 22937) ("c-reverse" 23723) ("c-prefix" 23982) ("c-suffix" 24238) ("c-append" 24458) ("c-append-map1" 24812) ("c-map1" 25378) ("c-map2" 25835) ("c-map3" 25835) ("c-map4" 25835) ("c-map5" 25835) ("c-fold1" 26649) ("c-unfold" 27472) ("c-unfold" 27472) ("c-filter" 28712) ("c-remove" 29111) ("c-find" 29462) ("c-find-tail" 29922) ("c-member" 30455) ("c-member" 30455) ("c-any1" 31751) ("c-every1" 32543) ("c-assoc" 33458) ("c-assoc" 33458) ("c-alist-delete" 34535) ("c-alist-delete" 34535) ("c-vector" 35596) ("c-list->vector" 35745) ("c-vector->list" 35938) ("c-vector-reverse" 36129) ("c-vector-prefix" 36355) ("c-vector-suffix" 36636) ("c-vector-append" 36883) ("c-vector-map1" 37236) ("c-u=" 37559) ("c-u<" 37925) ("c-u<=" 38247) ("c-u>" 38657) ("c-u>=" 38985) ("c-uzero?" 39393) ("c-ueven?" 39708) ("c-uodd?" 40081) ("c-u+" 40451) ("c-u-" 40698) ("c-u*" 41240) ("c-u/" 41695) ("c-ufactorial" 42286) ("c-udrop" 42820) ("c-utake" 43283) ("c-dadd1" 43715) ("c-dsub1" 44464) ("c-du" 45089) ("c-du" 45089) ("c-ud" 45865) ("c-ud" 45865) ("c-eqv?" 46682) ("c-eq?" 46825) ("c-equal?" 46965) ("c-number?" 47114) ("c-integer?" 47264) ("c-=" 47417) ("c-<" 47561) ("c->" 47709) ("c-<=" 47860) ("c->=" 48020) ("c-max" 48183) ("c-min" 48321) ("c-+" 48459) ("c-*" 48602) ("c--" 48751) ("c-/" 48897) ("c-remainder" 49040) ("c-floor" 49196) ("c-round" 49336) ("c-exact->inexact" 49476) ("c-inexact->exact" 49651) ("c-number->string" 49824) ("c-number->string" 49824) ("c-string->number" 50064) ("c-string->number" 50064) ("c-length" 50322) ("c-list-ref" 50466) ("c-symbol?" 50615) ("c-symbol->string" 50765) ("c-string->symbol" 50934) ("c-char?" 51103) ("c-char=?" 51254) ("c-string?" 51408) ("c-string" 51558) ("c-string-length" 51708) ("c-string-ref" 51875) ("c-string=?" 52032) ("c-string-ci=?" 52191) ("c-substring" 52359) ("c-substring" 52359) ("c-string-append" 52588) ("c-vector-length" 52758) ("c-vector-ref" 52923))
(def (sig (syntax "(ck s 'VAL)" (id ck)) (syntax "(ck s `VAL)" (id ck)) (syntax "(ck s (OP ...))" (id ck))) (p "This is the core " (tt "ck") " macro, which implements the CK abstract machine. In " (b "version 0.3.0 and later") ", this macro has been enhanced to support " (int-link "#quasiquotation" "quasiquotation") ".") (p "This macro's public interface has three shapes: with a quoted value, with a quasiquoted value, and with a CK-macro call.") (dl (dt "s") (dd "The stack, used internally by this macro. When initially invoking this macro, " (tt "s") " should be the empty list, e.g. " (tt "(ck () (c-cons '+ '(1 2)))") ".") (dt "'VAL") (dd "A quoted value. Can be a quoted list, symbol, or other literal value. The quote is necessary, even for literal values like strings, numbers, and booleans.") (dt "`VAL") (dd "A " (int-link "#quasiquotation" "quasiquoted") " value. This is syntactic sugar for " (tt "(c-quasiquote 'VAL)") ".") (dt "(OP ...)") (dd "A CK-macro call " (b "without the s argument") ", such as " (tt "(c-cons '+ '(1 2))") ". Nested calls are allowed, such as " (tt "(c-cons '+ (c-list '1 '2))") ".")))
(def (sig (procedure "(ck-wrapper proc)  →  macro transformer" (id ck-wrapper))) (p "Wrap a procedure in a CK-macro, returning a macro transformer that can be used with " (tt "define-syntax") " or " (tt "let-syntax") ".") (p (tt "ck-wrapper") " requires " (b "version 0.2.0 or later") " of the ck-macros egg. It is considered " (b "non-portable") " because it depends on " (int-link "/man/5/Module (chicken syntax)#explicit-renaming-macros" ((tt "er-macro-transformer"))) ", which is not defined in standard R5RS. However, it should work on any Scheme which defines " (tt "er-macro-transformer") " in the usual way.") (p "You can wrap any other expression that evaluates to a procedure, such as a procedure name, a lambda form, a \"let over lambda\" expression, etc. The expression will be evaluated once, when the call to " (tt "ck-wrapper") " is evaluated. Therefore, the procedure you are wrapping must be available in the syntax environment at macro expansion time. (In other words, you should use " (int-link "/man/5/Module (chicken syntax)#define-for-syntax" ((tt "define-for-syntax"))) ", " (int-link "/man/5/Modules#import-for-syntax" ((tt "import-for-syntax"))) ", etc.)") (p "Examples:") (highlight scheme ";;; Import iota from SRFI 1.\n(cond-expand\n  (chicken-4\n   (use-for-syntax (only srfi-1 iota)))\n  (chicken-5\n   (import-for-syntax (only (srfi 1) iota))))\n\n(define-syntax c-iota (ck-wrapper iota))\n\n(ck () (c-quote (c-iota '5)))\n;; ==> '(0 1 2 3 4)\n\n;;; A helper procedure that returns a closure.\n(define-for-syntax (make-adder n)\n  (lambda (x) (+ x n)))\n\n;;; Temporarily define a ck-wrapper around a closure.\n(let-syntax ((c-add2 (ck-wrapper (make-adder 2))))\n  ;; Map c-add2 over the result of c-iota.\n  (ck () (c-quote (c-map1 '(c-add2) (c-iota '5)))))\n;; ==> '(2 3 4 5 6)"))
(def (sig (syntax "(c-quote X)  →  'X" (id c-quote))) (p "Adds an extra level of quotation to the argument. This is useful for macros that should expand to a quoted value.") (highlight scheme ";; Without c-quote\n(ck () (c-cons '+ '(1 2)))\n;; Expands to (+ 1 2), which evaluates to the number 3.\n\n;; With c-quote\n(ck () (c-quote (c-cons '+ '(1 2))))\n;; Expands to '(+ 1 2), a quoted list."))
(def (sig (syntax "(c-quasiquote X)  →  result" (id c-quasiquote))) (p "Implements " (int-link "#quasiquotation" "quasiquotation") ". Added in " (b "version 0.3.0") ".") (p "The core " (tt "ck") " macro has special support for converting " (tt "(quasiquote x)") " (also written as " (tt "`x") ") into " (tt "(c-quasiquote 'x)") ". Within a call to " (tt "c-quasiquote") ", you can use " (tt "(unquote y)") " (also written as " (tt ",y") ") and " (tt "(unquote-splicing z)") " (also written as " (tt ",@z") "). They are supported inside vectors as well as inside pairs/lists.") (highlight scheme ";; These expressions are exactly equivalent:\n(ck () `(define (foo) (list ,@(c-list '1 '2) ,(c-vector '3))))\n(ck () (c-quasiquote '(define (foo) (list ,@(c-list '1 '2) ,(c-vector '3)))))\n;; ==> (define (foo) (list 1 2 #(3)))\n\n(ck () `#(1 ,@(c-list '2 '3)))\n(ck () (c-quasiquote '#(1 ,@(c-list '2 '3))))\n;; ==> #(1 2 3)"))
(def (sig (syntax "(c-eval '(OP ...))  →  result" (id c-eval))) (p "Takes a quoted operation and unquotes it, allowing the CK machine to expand it. Analogous to " (tt "eval") ".") (highlight scheme "(ck () (c-quote (c-eval '(c-cons 'a 'b))))\n;; ==> '(a . b)"))
(def (sig (syntax "(c-call '(OP ...) X ...)  →  result" (id c-call))) (p "Like " (tt "c-eval") ", but adds the given arguments on to the end of the operation. Analogous to a lambda call in normal Scheme code.") (highlight scheme "(ck () (c-quote (c-call '(c-cons 'a) 'b)))\n;; ==> '(a . b)"))
(def (sig (syntax "(c-apply '(OP ...) X ... '(Y ...))  →  result" (id c-apply))) (p "Like " (tt "c-call") ", but the last argument is a list of more arguments. " (b "Prior to version 0.2.0") ", the arguments in the final list required an extra level of quoting. Analogous to " (tt "apply") ".") (highlight scheme "(ck () (c-quote (c-apply '(c-list) 'a '(b) '(c d))))\n;; ==> '(a (b) c d)"))
(def (sig (syntax "(c-compose '((OP-N ...) ... (OP-1 ...)) X ...)  →  result" (id c-compose))) (p "Compose one or more CK-macros and apply them to the arguments. Calls the right-most " (tt "OP") " with the arguments " (tt "X ...") ", then calls the next-right-most " (tt "OP") " with that result, and so on:") (pre "(OP-N ... (OP-2 ... (OP-1 ... X ...)))") (p (tt "OP-1") " must accept all the " (tt "X") "s as arguments, and the other " (tt "OP") "s must each accept one argument (the result of the previous operation). See also " (tt "c-rcompose") ", which is more efficient. Added in " (b "version 0.2.0")) (highlight scheme "(ck () (c-compose '((c-car) (c-cdr)) '(1 2 3)))\n;; ==> 2\n\n;;; Map over a list of lists to see which are not empty.\n(ck () (c-quote (c-map1 '(c-compose '((c-not) (c-null?)))\n                        '((1) () (2 3)))))\n;; ==> '(#t #f #t)"))
(def (sig (syntax "(c-rcompose '((OP-1 ...) ... (OP-N ...)) X ...)  →  result" (id c-rcompose))) (p "Like " (tt "c-compose") ", but the operations are called in the reverse order (left to right). This is more efficient than " (tt "c-compose") ". Added in " (b "version 0.2.0")))
(def (sig (syntax "(c-flip '(OP ...) X Y)  →  (OP ... Y X)" (id c-flip))) (p "Calls the operation with the two extra arguments in reverse order. Added in " (b "version 0.3.0") "."))
(def (sig (syntax "(c-branch '((OP ...) ...) X ...)  →  '(result ...)" (id c-branch))) (p "Yields a list of the results of calling each operation with the " (tt "X") "s. Added in " (b "version 0.3.0") ".") (highlight scheme "(ck () (c-quote\n        (c-branch '((c-list)\n                    (c-cons)\n                    (c-* '10))\n                  '3 '5)))\n;; '((3 5)\n;;   (3 . 5)\n;;   150)"))
(def (sig (syntax "(c-identity X)  →  X" (id c-identity))) (p "Simply yields the value as given. Sometimes useful for higher-order macros like " (tt "c-filter") ".") (highlight scheme "(ck () (c-quote (c-identity 'a)))\n;; ==> 'a"))
(def (sig (syntax "(c-constantly X Y ...)  →  X" (id c-constantly))) (p "Always yields " (tt "X") ", regardless of the other arguments. May be useful for some higher-order macros. Added in " (b "version 0.3.0") "."))
(def (sig (syntax "(c-make-rules '(L ...) '(P X) ...)  →  '(syntax-rules ...)" (id c-make-rules))) (p "Build a CK-macro based on syntax-rules. Added in " (b "version 0.3.0") ".") (p "Given a list of zero or more literal symbols, and one or more pattern/expression lists, yields a syntax-rules form for a CK-macro with the following behavior:") (ul (li "Given argument(s) that match any pattern " (tt "P") ", yields the value of the associated expression " (tt "X") ", which may use identifiers from " (tt "P") ". Fails if no pattern matches.")) (p "Each pattern " (tt "P") " is a list of zero or more sub-patterns, which will be matched (as with syntax-rules) against the already-evaluated and quoted arguments given to the new CK-macro. Alternatively, " (tt "P") " may be an identifier which will capture all arguments as a list.") (p "Each expression " (tt "X") " is a single CK-macro expression or quoted value. Identifiers from the pattern can be used in the expression, as with syntax-rules.") (p "Symbols in the literals list " (tt "(L ...)") " will be treated as literal identifiers in patterns. Additionally, " (tt "quote") " is always treated as a literal identifier.") (p "Caveats:") (ul (li "Using " (tt "...") " in a pattern or expression may not work portably with all Scheme systems.") (li "Symbols begining with " (tt "%ck:") " are reserved for internal use and must not appear in any " (tt "L") ", " (tt "P") ", or " (tt "X") ".")) (highlight scheme ";; Contrived example\n(ck () `(define-syntax c-math\n          ,(c-make-rules '(add subtract)\n            '(('add 'x 'y)\n              (c-+ 'x 'y))\n            '(('subtract 'x 'y)\n              (c-- 'x 'y)))))\n\n;; The above is basically equivalent to:\n;;   (define-syntax c-math\n;;     (syntax-rules (add subtract quote)\n;;       ((_ s 'add 'x 'y)\n;;        (ck s (c-+ 'x 'y)))\n;;       ((_ s 'subtract 'x 'y)\n;;        (ck s (c-- 'x 'y)))))\n\n(ck () (c-quote (c-math 'add '3 '1)))\n;; ==> 4\n\n(ck () (c-quote (c-math 'subtract '3 '1)))\n;; ==> 2"))
(def (sig (syntax "(c-make-next '(X1 X2 ...))  →  '(syntax-rules ...)" (id c-make-next))) (p "Build a CK-macro that yields the next item in a sequence. Added in " (b "version 0.3.0") ".") (p "Given a list of unique items, yields a syntax-rules form for a CK-macro with the following behavior:") (ul (li "Given an item in the list, yields the item following it. Yields " (tt "'#f") " if given the final item or an item not in the list.")) (p "E.g. with a list of increasing integers, the CK-macro behaves like " (tt "c-dadd1") ". With a list of decreasing integers, it behaves like " (tt "c-dsub1") ".") (p "The list must have at least two items, with no duplicates. The items should be literal constants: booleans, numbers, strings, characters; or (possibly nested) pairs, lists, or vectors of those things. Symbols are allowed but the result may not be what you expect because they are treated as identifiers in the patterns.") (p "Be advised that compilation can be very slow if there are many items because it generates a syntax-rules with many branches.") (highlight scheme "(ck () `(define-syntax c-next-square\n          ,(c-make-next '(0 1 4 9 16))))\n\n;; The above is basically equivalent to:\n;; (define-syntax c-next-square\n;;  (syntax-rules (quote)\n;;    ((_ s '0) (ck s '1))\n;;    ((_ s '1) (ck s '4))\n;;    ((_ s '4) (ck s '9))\n;;    ((_ s '9) (ck s '16))\n;;    ((_ s otherwise) (ck s '#f))))\n\n(ck () (c-next-square '4))\n;; ==> '9\n(ck () (c-next-square '16))\n;; ==> '#f"))
(def (sig (syntax "(c-not X)  →  '#t or '#f" (id c-not))) (p "Yields " (tt "'#t") " if the argument is " (tt "'#f") ", otherwise yields " (tt "'#f") ". Analogous to " (tt "not") "."))
(def (sig (syntax "(c-true X ...)  →  '#t" (id c-true))) (p "Always yields " (tt "'#t") ", regardless of its arguments. May be useful for some higher-order macros. Equivalent to " (tt "(c-constantly '#t X ...)") ". Added in " (b "version 0.2.0") ".") (highlight scheme ";;; Recursively check if two structure have the same length,\n;;; nesting, etc, while ignoring the value of the atoms.\n(ck () (c-compare? '(c-true) '(1 #(2) 3) '(a #(b) c)))\n;; ==> '#t"))
(def (sig (syntax "(c-false X ...)  →  '#f" (id c-false))) (p "Always yields " (tt "'#f") ", regardless of its arguments. May be useful for some higher-order macros. Equivalent to " (tt "(c-constantly '#f X ...)") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-if TEST PASS FAIL)  →  PASS or FAIL" (id c-if))) (p "Conditional branching. If " (tt "TEST") " is " (tt "'#f") ", this yields " (tt "FAIL") ". Otherwise it yields " (tt "PASS") ".") (p "Due to the way the CK machine works, both branches will be expanded, then the unneeded branch will be discarded. If you only want the needed branch to be expanded (e.g. because the branches are complex and slow to expand, or because it would be an error to expand the unneeded branch), use " (tt "c-if*") " instead.") (p "Analogous to " (tt "(lambda (test pass fail) (if test pass fail))") ".") (highlight scheme "(ck () (c-quote (c-if (c-pair? '(x))\n                      'pair\n                      'not-pair)))\n;; ==> 'pair\n\n(ck () (c-quote (c-if (c-pair? 'x)\n                      'pair\n                      'not-pair)))\n;; ==> 'not-pair"))
(def (sig (syntax "(c-if* TEST 'PASS 'FAIL)  →  PASS or FAIL" (id c-if*))) (p "Similar to " (tt "c-if") ", except that the branches must have an extra level of quoting, and only one branch will be expanded. This is more similar to how " (tt "if") " behaves, but it is a bit awkward to use.") (p "Analogous to " (tt "(lambda (test pass fail) (if test (eval pass) (eval fail)))")) (highlight scheme "(ck () (c-quote (c-if* (c-pair? '(x))\n                       '(c-car '(x))\n                       ''not-pair)))\n;; ==> 'x\n\n(ck () (c-quote (c-if* (c-pair? 'x)\n                       '(c-car 'x)\n                       ''not-pair)))\n;; ==> 'not-pair"))
(def (sig (syntax "(c-or X ...)  →  item or '#f" (id c-or))) (p "Yields the first argument that is not " (tt "'#f") ". Yields " (tt "'#f") " if all of the arguments are " (tt "'#f") ", or if there are no arguments.") (p "Roughly analogous to " (tt "or") ", except all arguments are expanded. If you only want to expand the arguments that are needed, use " (tt "c-or*") " instead."))
(def (sig (syntax "(c-or* 'X ...)  →  item or '#f" (id c-or*))) (p "Similar to " (tt "c-or") ", except that all the arguments must have an extra level of quoting, and the arguments will be expanded one at a time until a non-" (tt "'#f") " value is found. This is more similar to how " (tt "or") " behaves, but it is a bit awkward to use."))
(def (sig (syntax "(c-and X ...)  →  item or '#f" (id c-and))) (p "If all arguments are not " (tt "'#f") ", yields the last argument. If any of the arguments is " (tt "'#f") ", yields " (tt "'#f") ". If there are no arguments, yields " (tt "'#t") ".") (p "Roughly analogous to " (tt "and") ", except all arguments are expanded. If you only want to expand the arguments that are needed, use " (tt "c-and*") " instead."))
(def (sig (syntax "(c-and* X ...)  →  item or '#f" (id c-and*))) (p "Similar to " (tt "c-and") ", except that all the arguments must have an extra level of quoting, and the arguments will be expanded one at a time until a " (tt "'#f") " value is found. This is more similar to how " (tt "and") " behaves, but it is a bit awkward to use."))
(def (sig (syntax "(c-null? X)  →  '#t or '#f" (id c-null?))) (p "Yields " (tt "'#t") " if " (tt "X") " is the empty list, " (tt "'()") ". Otherwise yields " (tt "'#f") ". Analogous to " (tt "null?") "."))
(def (sig (syntax "(c-pair? X)  →  '#t or '#f" (id c-pair?))) (p "Yields " (tt "'#t") " if " (tt "X") " is a dotted pair or a non-empty list. Otherwise yields " (tt "'#f") ". Analogous to " (tt "pair?") "."))
(def (sig (syntax "(c-not-pair? X)  →  '#t or '#f" (id c-not-pair?))) (p "Opposite of " (tt "c-pair?") ". Analogous to " (tt "not-pair?") " from SRFI 1."))
(def (sig (syntax "(c-vector? X)  →  '#t or '#f" (id c-vector?))) (p "Yields " (tt "'#t") " if " (tt "X") " is a vector. Otherwise yields " (tt "'#f") ". Analogous to " (tt "vector?") ".") (highlight scheme "(ck () (c-quote (c-vector? '#(a))))\n;; ==> '#t"))
(def (sig (syntax "(c-boolean? X)  →  '#t or '#f" (id c-boolean?))) (p "Yields " (tt "'#t") " if " (tt "X") " is either " (tt "'#t") " or " (tt "'#f") ". Otherwise yields " (tt "'#f") ". Analogous to " (tt "boolean?") "."))
(def (sig (syntax "(c-sym-eq? X Y)  →  '#t or '#f" (id c-sym-eq?))) (p (b "ATTENTION:") " This CK-macro has " (int-link "#pitfalls-of-c-sym-eq" "major pitfalls") " that you should be aware of. If you do not require strict R5RS portability, it is recommended to use " (tt "c-eq?") " instead.") (p "Yields " (tt "'#t") " if " (tt "X") " and " (tt "Y") " are the same symbol, otherwise yields " (tt "'#f") ". " (tt "X") " should be a symbol. " (tt "Y") " can be any value. Some Scheme implementations allow " (tt "X") " to be other types, but this macro is only portable if " (tt "X") " is a symbol.") (p "Roughly analogous to " (tt "eq?") ", except it only works (portably) with symbols. Based on " (tt "symbol-eq?") " from the original implementation."))
(def (sig (syntax "(c-sym-equal? X Y)  →  '#t or '#f" (id c-sym-equal?))) (p (b "ATTENTION:") " This CK-macro has " (int-link "#pitfalls-of-c-sym-eq" "major pitfalls") " that you should be aware of. If you do not require strict R5RS portability, it is recommended to use " (tt "c-equal?") " instead.") (p "Similar to " (tt "c-sym-eq?") ", except it recursively compares pairs, lists, and vectors.") (p "Roughly analogous to " (tt "equal?") ", except it only works (portably) with symbols, pairs, lists, vectors, and nested combinations of those things."))
(def (sig (syntax "(c-compare? '(OP ...) X Y)  →  '#t or '#f" (id c-compare?))) (p "Recursively compares atoms, pairs, lists, or vectors, using " (tt "OP") " as the predicate to compare atoms. Similar to " (tt "equal?") " but with a custom predicate. Added in " (b "version 0.2.0") ".") (p (tt "OP") " will be called with two arguments: an atom of " (tt "X") ", and the corresponding atom of " (tt "Y") ". In other words, the Nth atom of " (tt "X") " will be compared with the Nth atom of " (tt "Y") ", descending recursively into nested structures. If " (tt "X") " and " (tt "Y") " are themselves atoms, they are compared directly with " (tt "OP") ".") (p "Yields " (tt "'#f") " if " (tt "X") " and " (tt "Y") " have dissimilar structures (length, nesting, type), or if " (tt "OP") " yields " (tt "'#f") " for any corresponding atoms of " (tt "X") " and " (tt "Y") ". Otherwise yields " (tt "'#t") ".") (highlight scheme "(ck () (c-compare? '(c-string-ci=?) '#(\"a\" (\"b\")) '#(\"A\" (\"B\"))))\n;; ==> #t\n\n;;; X is a vector with a list, but Y is a list with a vector.\n;;; The structures are dissimilar.\n(ck () (c-compare? '(c-string-ci=?) '#(\"a\" (\"b\")) '(\"a\" #(\"b\"))))\n;; ==> #f\n\n;;; Can use any predicate. Here, X and Y have same structure,\n;;; and each atom of X is less than the correponding atom of Y.\n(ck () (c-compare? '(c-<) '(1 #(5)) '(2 #(6))))\n;; ==> #t\n\n;;; Can compare atoms directly.\n(ck () (c-compare? '(c-<) '1 '2))\n;; ==> #t"))
(def (sig (syntax "(c-cons X Y)  →  '(X . Y)" (id c-cons))) (p "Yields a pair with the two given arguments. Analogous to " (tt "cons") ".") (highlight scheme "(ck () (c-quote (c-cons 'a 'b)))\n;; ==> '(a . b)\n\n(ck () (c-quote (c-cons '+ '(1 2))))\n;; ==> '(+ 1 2)\n\n(ck () (c-quote (c-cons '+ (c-cons '1 (c-cons '2 '())))))\n;; ==> '(+ 1 2)"))
(def (sig (syntax "(c-cons* X ... Y Z)  →  '(X ... Y . Z)" (id c-cons*))) (p "Yields a list from consing all the arguments together in a chain. If the final argument Z is a list, the result will be a proper list. Otherwise it will be a \"dotted list\". Analogous to " (tt "cons*") " from SRFI 1. Added in " (b "version 0.3.0") ".") (highlight scheme "(ck () (c-quote (c-cons* 'a 'b 'c 'd)))\n;; ==> '(a b c . d)\n(ck () (c-quote (c-cons* 'a 'b 'c '(d))))\n;; ==> '(a b c d)"))
(def (sig (syntax "(c-xcons X Y)  →  '(Y . X)" (id c-xcons))) (p "Like " (tt "c-cons") ", but exchanges the order of arguments. Analogous to " (tt "xcons") " from SRFI 1. Added in " (b "version 0.2.0") ".") (highlight scheme "(ck () (c-quote (c-xcons 'a 'b)))\n;; ==> '(b . a)"))
(def (sig (syntax "(c-list X ...)  →  list" (id c-list))) (p "Yields a list containing the given items. Analogous to " (tt "list") ".") (highlight scheme "(ck () (c-quote (c-list)))\n;; ==> '()\n(ck () (c-quote (c-list 'a 'b 'c)))\n;; ==> '(a b c)"))
(def (sig (syntax "(c-car P)  →  item" (id c-car))) (p "Yields the head of the given pair. Analogous to " (tt "car") ".") (highlight scheme "(ck () (c-quote (c-car '(a . b))))\n;; ==> 'a\n\n(ck () (c-quote (c-car '(a b))))\n;; ==> 'a"))
(def (sig (syntax "(c-cdr P)  →  tail" (id c-cdr))) (p "Yields the tail of the given pair. Analogous to " (tt "cdr") ".") (highlight scheme "(ck () (c-quote (c-cdr '(a . b))))\n;; ==> 'b\n\n(ck () (c-quote (c-cdr '(a b))))\n;; ==> '(b)"))
(def (sig (syntax "(c-first   L)  →  item" (id c-first)) (syntax "(c-second  L)  →  item" (id c-second)) (syntax "(c-third   L)  →  item" (id c-third)) (syntax "(c-fourth  L)  →  item" (id c-fourth)) (syntax "(c-fifth   L)  →  item" (id c-fifth)) (syntax "(c-sixth   L)  →  item" (id c-sixth)) (syntax "(c-seventh L)  →  item" (id c-seventh)) (syntax "(c-eighth  L)  →  item" (id c-eighth)) (syntax "(c-ninth   L)  →  item" (id c-ninth)) (syntax "(c-tenth   L)  →  item" (id c-tenth))) (p "Yields the Nth item of the given list. Fails if the list is too short.") (p "Analogous to " (tt "first") " ... " (tt "tenth") " from SRFI 1.") (highlight scheme "(ck () (c-quote (c-first  '(a b c d e f g h i j k))))  ; ==> 'a\n(ck () (c-quote (c-second '(a b c d e f g h i j k))))  ; ==> 'b\n(ck () (c-quote (c-third  '(a b c d e f g h i j k))))  ; ==> 'c\n;;; ...\n(ck () (c-quote (c-tenth  '(a b c d e f g h i j k))))  ; ==> 'j"))
(def (sig (syntax "(c-last L)  →  item" (id c-last))) (p "Yields the last value of the given list. Fails if the list is empty or is not a proper list.") (p "Analogous to " (tt "last") " from SRFI 1.") (highlight scheme "(ck () (c-quote (c-last '(a b c))))    ; ==> 'c\n(ck () (c-quote (c-last '(a b . c))))  ; ==> ERROR!"))
(def (sig (syntax "(c-last-pair L)  →  pair" (id c-last-pair))) (p "Yields the last pair of the given list. Fails if the list is empty.") (p "Analogous to " (tt "last-pair") " from SRFI 1.") (highlight scheme "(ck () (c-quote (c-last-pair '(a b c))))    ; ==> '(c)\n(ck () (c-quote (c-last-pair '(a b . c))))  ; ==> '(b . c)"))
(def (sig (syntax "(c-drop1 L)  →  list" (id c-drop1)) (syntax "(c-drop2 L)  →  list" (id c-drop2)) (syntax "(c-drop3 L)  →  list" (id c-drop3)) (syntax "(c-drop4 L)  →  list" (id c-drop4)) (syntax "(c-drop5 L)  →  list" (id c-drop5))) (p "Drops a predefined number of items from the front of the given list. Fails if the list is too short. See also " (tt "c-udrop") ".") (p "Analogous to " (tt "(drop L N)") " from SRFI 1.") (highlight scheme "(ck () (c-quote (c-drop1 '(a b c d e f g))))  ; ==> '(b c d e f g)\n(ck () (c-quote (c-drop2 '(a b c d e f g))))  ; ==> '(c d e f g)\n(ck () (c-quote (c-drop3 '(a b c d e f g))))  ; ==> '(d e f g)\n(ck () (c-quote (c-drop4 '(a b c d e f g))))  ; ==> '(e f g)\n(ck () (c-quote (c-drop5 '(a b c d e f g))))  ; ==> '(f g)"))
(def (sig (syntax "(c-take1 L)  →  list" (id c-take1)) (syntax "(c-take2 L)  →  list" (id c-take2)) (syntax "(c-take3 L)  →  list" (id c-take3)) (syntax "(c-take4 L)  →  list" (id c-take4)) (syntax "(c-take5 L)  →  list" (id c-take5))) (p "Yields a list containing a predefined number of items from the front of the given list. Fails if the list is too short. See also " (tt "c-utake") ".") (p "Analogous to " (tt "(take L N)") " from SRFI 1.") (highlight scheme "(ck () (c-quote (c-take1 '(a b c d e f g))))  ; ==> '(a)\n(ck () (c-quote (c-take2 '(a b c d e f g))))  ; ==> '(a b)\n(ck () (c-quote (c-take3 '(a b c d e f g))))  ; ==> '(a b c)\n(ck () (c-quote (c-take4 '(a b c d e f g))))  ; ==> '(a b c d)\n(ck () (c-quote (c-take5 '(a b c d e f g))))  ; ==> '(a b c d e)"))
(def (sig (syntax "(c-reverse L)  →  list" (id c-reverse))) (p "Yields the given list in reverse order. Fails if the list is not a proper list. Analogous to " (tt "reverse") ".") (highlight scheme "(ck () (c-quote (c-reverse '(a b c))))\n;; ==> '(c b a)"))
(def (sig (syntax "(c-prefix L X ...)  →  list" (id c-prefix))) (p "Yields the given list with the extra arguments added to the front. Added in " (b "version 0.3.0") ".") (highlight scheme "(ck () (c-quote (c-prefix '(c d) 'a 'b)))\n;; ==> '(a b c d)"))
(def (sig (syntax "(c-suffix L X ...)  →  list" (id c-suffix))) (p "Yields the given list with the extra arguments added to the end.") (highlight scheme "(ck () (c-quote (c-suffix '(a b) 'c 'd)))\n;; ==> '(a b c d)"))
(def (sig (syntax "(c-append L ...)  →  list" (id c-append))) (p "Appends the given lists. Analogous to " (tt "append") ".") (highlight scheme "(ck () (c-quote (c-append)))\n;; ==> '()\n\n(ck () (c-quote (c-append '(+) (c-append '(1) '(2)))))\n;; ==> '(+ 1 2)\n\n(ck () (c-quote (c-append '(define foo) '((+ 1 2)))))\n;; ==> '(define foo (+ 1 2 3))"))
(def (sig (syntax "(c-append-map1 '(OP ...) L)  →  list" (id c-append-map1))) (p "Yields a list by calling the quoted operation on each item in the list, then appending the results. The operation must be a CK-macro that yields a list.") (p "Analogous to " (tt "append-map") " from SFRI-1, but only accepts one list. " (b "Prior to version 0.2.0") ", this was named " (tt "c-append-map") ". This was named " (tt "c-concatMap") " in the original implementation.") (highlight scheme "(ck () (c-quote (c-append-map1 '(c-list 'a 'b) '(1 2))))\n;; ==> '(a b 1 a b 2)"))
(def (sig (syntax "(c-map1 '(OP ...) L)  →  list" (id c-map1))) (p "Yields a list by calling the quoted operation on each item in the given list. Analogous to " (tt "map") ", but only accepts one list. (See also " (tt "c-map2") " ... " (tt "c-map5") " for versions that accept more lists.) " (b "Prior to version 0.2.0") ", this was named " (tt "c-map") ".") (highlight scheme "(ck () (c-quote (c-map1 '(c-cons 'a) '(1 2))))\n;; ==> '((a . 1) (a . 2))"))
(def (sig (syntax "(c-map2 '(OP ...) L1 L2)  →  list" (id c-map2)) (syntax "(c-map3 '(OP ...) L1 L2 L3)  →  list" (id c-map3)) (syntax "(c-map4 '(OP ...) L1 L2 L3 L4)  →  list" (id c-map4)) (syntax "(c-map5 '(OP ...) L1 L2 L3 L4 L5)  →  list" (id c-map5))) (p "Like " (tt "c-map1") ", but they accept exactly two, three, four, or five lists respectively. " (tt "OP") " must accept two, three, four, or five extra arguments. If the lists are different lengths, terminates when the shortest list runs out. Analogous to " (tt "map") " from SRFI 1, but they accept a specific number of lists. Added in " (b "version 0.2.0") ".") (highlight scheme ";; The argument '(1 2) is shortest so the result only has two items.\n(ck () (c-quote (c-map3 '(c-list) '(a b c) '(1 2) '(x y z))))\n;; ==> '((a 1 x) (b 2 y))"))
(def (sig (syntax "(c-fold1 '(OP ...) INIT L)  →  result" (id c-fold1))) (p "Yield a value by repeatedly calling the quoted operation with each item from the list and the previous result.") (p "If the list is empty, yields " (tt "INIT") ". Otherwise, the operation is first called with two arguments: the first item of the list, and " (tt "INIT") ". Then, the operation is repeatedly called with the next item of the list and the previous result, until it reaches the end of the list. Yields the final result.") (p "Analogous to " (tt "fold") " from SRFI 1, but only accepts one list. " (b "Prior to version 0.2.0") ", this was named " (tt "c-fold") ".") (highlight scheme "(ck () (c-quote (c-fold1 '(c-cons) '(x) '())))\n;; ==> '(x)\n(ck () (c-quote (c-fold1 '(c-cons) '(x) '(a b c d e f))))\n;; ==> '(f e d c b a x)"))
(def (sig (syntax "(c-unfold '(P ...) '(F ...) '(G ...) SEED)  →  list" (id c-unfold)) (syntax "(c-unfold '(P ...) '(F ...) '(G ...) SEED '(TAIL-GEN ...))  →  list" (id c-unfold))) (p "Generate a list by recursively \"unfolding\" from a seed. Analogous to " (tt "unfold") " from SRFI 1. Added in " (b "version 0.3.0") ".") (p "Takes several operations which are called with the seed:") (ul (li (tt "(P ... SEED)") " should yield non-" (tt "'#f") " if it is time to stop generating.") (li (tt "(F ... SEED)") " should yield an item to be appended to the list.") (li (tt "(G ... SEED)") " should yield the next " (tt "SEED") ".") (li (tt "(TAIL-GEN ... SEED)") " should yield the tail of the list. Called with the final " (tt "SEED") " after " (tt "P") " yields non-" (tt "'#f") ". If omitted, " (tt "'(TAIL-GEN ...)") " defaults to " (tt "'(c-constantly '())") ".")) (highlight scheme "(ck () (c-quote\n        (c-unfold '(c-> '1)                        ; P\n                  '(c-identity)                    ; F\n                  '(c-dsub1)                       ; G\n                  '10                              ; SEED\n                  '(c-constantly '(BLASTOFF!)))))  ; TAIL-GEN\n;; ==> '(10 9 8 7 6 5 4 3 2 1 BLASTOFF!)"))
(def (sig (syntax "(c-filter '(OP ...) L)  →  list" (id c-filter))) (p "Yields a list by calling the predicate operation on each item in the list, and discarding any item for which the test yields " (tt "'#f") ". Analogous to " (tt "filter") " from SRFI 1.") (highlight scheme "(ck () (c-quote (c-filter '(c-pair?)\n                          '(a (b . c) 1 (d e) #t))))\n;; ==> '((b . c) (d e))"))
(def (sig (syntax "(c-remove '(OP ...) L)  →  list" (id c-remove))) (p "Opposite of " (tt "c-filter") ". Discards items that pass the test, keeps items that fail the test. Analogous to " (tt "remove") " from SRFI 1.") (highlight scheme "(ck () (c-quote (c-remove '(c-pair?)\n                          '(a (b . c) 1 (d e) #t))))\n;; ==> '(a 1 #t)"))
(def (sig (syntax "(c-find '(OP ...) L)  →  item or '#f" (id c-find))) (p "Searches the list for the first item that passes the predicate operation (i.e. the predicate yields a non-" (tt "'#f") " value), then yields that item. Yields " (tt "'#f") " if no item passes the predicate.") (p "Analogous to " (tt "find") " from SRFI 1.") (highlight scheme "(ck () (c-quote (c-find '(c-pair?)\n                        '(a (b . c) 1 (d e) #t))))\n;; ==> '(b . c)"))
(def (sig (syntax "(c-find-tail '(OP ...) L)  →  pair or '#f" (id c-find-tail))) (p "Searches the list for the first item that passes the predicate operation (i.e. the predicate yields a non-" (tt "'#f") " value), then yields the tail of the list starting with that item. Yields " (tt "'#f") " if no item passes the predicate.") (p "Analogous to " (tt "find-tail") " from SRFI 1.") (highlight scheme "(ck () (c-quote (c-find-tail '(c-pair?)\n                             '(a (b . c) 1 (d e) #t))))\n;; ==> '((b . c) 1 (d e) #t)"))
(def (sig (syntax "(c-member X L)  →  '#t or '#f" (id c-member)) (syntax "(c-member X L '(OP ...))  →  '#t or '#f" (id c-member))) (p (b "ATTENTION:") " When using the default comparison operator, this CK-macro has " (int-link "#pitfalls-of-c-sym-eq" "major pitfalls") " that you should be aware of. If you do not require strict R5RS portability, it is recommended to use the comparison operator " (tt "'(c-equal?)") " instead.") (p "Searches the list for the first occurance of " (tt "X") ", then yields the tail of the list starting with that item. Yields " (tt "'#f") " if the list does not contain " (tt "X") ".") (p "Uses " (tt "'(OP ...)") " for comparison, or " (tt "'(c-sym-equal?)") " if the operation is omitted. So by default, " (tt "X") " must be a symbol, list, pair, vector, or nested combination of those things.") (p "Same as " (tt "(c-find-tail '(OP ... X) L)") ". Roughly analogous to " (tt "member") " except for the default allowed types.") (highlight scheme "(ck () (c-quote (c-member 'b '(a b c))))\n;; ==> '(b c)\n\n(ck () (c-quote (c-member 'x '(a b c))))\n;; ==> '#f\n\n(ck () (c-quote (c-member '(a b c)\n                          '((a) (x y z) (a b))\n                          '(c-u=))))\n;; ==> '((x y z) (a b))\n;; Because (c-u= '(a b c) '(x y z)) yields '#t"))
(def (sig (syntax "(c-any1 '(OP ...) L)  →  result or '#f" (id c-any1))) (p "Calls the operation on each value in the given list until it finds a result that is not " (tt "'#f") ", then yields that result. Yields " (tt "'#f") " if the predicate yields " (tt "'#f") " for all items in the list, or if the list is empty.") (p "Analogous to " (tt "any") " from SRFI 1, but only accepts one list. " (b "Prior to version 0.2.0") ", this was named " (tt "c-any") ".") (highlight scheme "(ck () (c-quote (c-any1 '(c-pair?) '())))\n;; ==> '#f\n(ck () (c-quote (c-any1 '(c-pair?) '(a b c))))\n;; ==> '#f\n(ck () (c-quote (c-any1 '(c-pair?) '(a (b . c)))))\n;; ==> '#t\n\n(ck () (c-quote (c-any1 '(c-cons 'z) '(a b c))))\n;; ==> '(1 . a)\n;; Because (c-cons 'z 'a) yields a value that is not '#f."))
(def (sig (syntax "(c-every1 '(OP ...) L)  →  result or '#f" (id c-every1))) (p "Calls the operation on each value in the given list until it finds a result that is " (tt "'#f") ", then yields " (tt "'#f") ". If the predicate yields a non-" (tt "'#f") " value for every item in the list, this yields the result of calling the predicate on the last item. Yields " (tt "'#t") " if the list is empty.") (p "Analogous to " (tt "every") " from SRFI 1, but only accepts one list. " (b "Prior to version 0.2.0") ", this was named " (tt "c-every") ".") (highlight scheme "(ck () (c-quote (c-every1 '(c-pair?) '())))\n;; ==> '#t\n(ck () (c-quote (c-every1 '(c-pair?) '(a (b . c)))))\n;; ==> '#f\n(ck () (c-quote (c-every1 '(c-pair?) '((a . b) (b . c)))))\n;; ==> '#t\n\n(ck () (c-quote (c-every1 '(c-cons 'z) '(a b c))))\n;; ==> '(z . c)\n;; Because all results were non-'#f and (c-cons 'z 'c) was the final operation."))
(def (sig (syntax "(c-assoc KEY ALIST)  →  pair or '#f" (id c-assoc)) (syntax "(c-assoc KEY ALIST '(OP ...))  →  pair or '#f" (id c-assoc))) (p (b "ATTENTION:") " When using the default comparison operator, this CK-macro has " (int-link "#pitfalls-of-c-sym-eq" "major pitfalls") " that you should be aware of. If you do not require strict R5RS portability, it is recommended to use the comparison operator " (tt "'(c-equal?)") " instead.") (p "Searches " (tt "ALIST") " for the first pair whose car matches " (tt "KEY") ", then yields that pair. Yields " (tt "'#f") " if no match is found. " (tt "ALIST") " must be an association list, i.e. a list of pairs.") (p "Uses " (tt "'(OP ...)") " for comparison, or " (tt "'(c-sym-equal?)") " if " (tt "'(OP ...)") " is omitted.") (p "Analogous to " (tt "assoc") " from SRFI 1.") (highlight scheme "(ck () (c-quote (c-assoc 'x '((a . 1) (b . 2) (a . 3)))))\n;; ==> '#f\n(ck () (c-quote (c-assoc 'a '((a . 1) (b . 2) (a . 3)))))\n;; ==> '(a . 1)\n(ck () (c-quote (c-assoc '(a) '((a . 1) (b . 2) ((a) . 3)))))\n;; ==> '((a) . 3)"))
(def (sig (syntax "(c-alist-delete KEY ALIST)  →  list" (id c-alist-delete)) (syntax "(c-alist-delete KEY ALIST '(OP ...))  →  list" (id c-alist-delete))) (p (b "ATTENTION:") " When using the default comparison operator, this CK-macro has " (int-link "#pitfalls-of-c-sym-eq" "major pitfalls") " that you should be aware of. If you do not require strict R5RS portability, it is recommended to use the comparison operator " (tt "'(c-equal?)") " instead.") (p "Removes all pairs in " (tt "ALIST") " whose car matches " (tt "KEY") ". " (tt "ALIST") " must be an association list, i.e. a list of pairs.") (p "Uses " (tt "'(OP ...)") " for comparison, or " (tt "'(c-sym-equal?)") " if " (tt "'(OP ...)") " is omitted.") (p "Analogous to " (tt "alist-delete") " from SRFI 1. Based on " (tt "c-delete-assoc") " from the original implementation.") (highlight scheme "(ck () (c-quote (c-alist-delete 'a '((a . 1) (b . 2) (a . 3) (c . 4)))))\n;; ==> '((b . 2) (c . 4)\n(ck () (c-quote (c-alist-delete '(a) '((a . 1) (b . 2) ((a) . 3)))))\n;; ==> '((a . 1) (b . 2))"))
(def (sig (syntax "(c-vector X ...)  →  vector" (id c-vector))) (p "Yields a vector containing the given items. Analogous to " (tt "vector") "."))
(def (sig (syntax "(c-list->vector L)  →  vector" (id c-list->vector))) (p "Yields a vector containing the same items as the given list. Analogous to " (tt "list->vector") " from SRFI 43."))
(def (sig (syntax "(c-vector->list V)  →  list" (id c-vector->list))) (p "Yields a list containing the same items as the given vector. Analogous to " (tt "vector->list") " from SRFI 43."))
(def (sig (syntax "(c-vector-reverse V)  →  vector" (id c-vector-reverse))) (p "Yields the given vector in reverse order. Similar to " (tt "vector-reverse-copy") " from SRFI 43, but does not take a start or end argument."))
(def (sig (syntax "(c-vector-prefix V X ...)  →  list" (id c-vector-prefix))) (p "Yields the given vector with the extra arguments added to the front. Added in " (b "version 0.3.0") ".") (highlight scheme "(ck () (c-quote (c-vector-prefix '#(c d) 'a 'b)))\n;; ==> '#(a b c d)"))
(def (sig (syntax "(c-vector-suffix V X ...)  →  vector" (id c-vector-suffix))) (p "Yields the given vector with the extra arguments added to the end.") (highlight scheme "(ck () (c-quote (c-vector-suffix '#(a b) 'c 'd)))\n;; ==> '#(a b c d)"))
(def (sig (syntax "(c-vector-append V ...)  →  vector" (id c-vector-append))) (p "Appends the given vectors. Analogous to " (tt "vector-append") " from SRFI 43, but only accepts two vectors.") (highlight scheme "(ck () (c-quote (c-vector-append)))\n;; ==> '#()\n\n(ck () (c-quote (c-vector-append '#(a b) '#(c d) '#(e f))))\n;; ==> '#(a b c d e f)"))
(def (sig (syntax "(c-vector-map1 '(OP ...) V)  →  vector" (id c-vector-map1))) (p "Yields a vector by calling the quoted operation on each item in the given vector. Analogous to " (tt "vector-map") " from SRFI 43, but only accepts one vector. " (b "Prior to version 0.2.0") ", this was named " (tt "c-vector-map") "."))
(def (sig (syntax "(c-u= U1 U2)  →  '#t or '#f" (id c-u=))) (p "Unary equality. Yields " (tt "'#t") " if the two lists have the same lengths, otherwise yields " (tt "'#f") ".") (highlight scheme "(ck () (c-quote (c-u= '(a b c) '(a b c))))\n;; ==> '#t\n(ck () (c-quote (c-u= '(1 2 3) '(a b c))))\n;; ==> '#t\n(ck () (c-quote (c-u= '(1 2) '(a b c))))\n;; ==> '#f"))
(def (sig (syntax "(c-u< U1 U2)  →  '#t or '#f" (id c-u<))) (p "Unary less-than. Yields " (tt "'#t") " if the first list is shorter than the second list, otherwise yields " (tt "'#f") ".") (highlight scheme "(ck () (c-quote (c-u< '(1 2) '(a b c))))\n;; ==> '#t\n(ck () (c-quote (c-u< '(1 2 3) '(a b c))))\n;; ==> '#f"))
(def (sig (syntax "(c-u<= U1 U2)  →  '#t or '#f" (id c-u<=))) (p "Unary less-than-or-equals. Yields " (tt "'#t") " if first list is the same length or shorter than the second list, otherwise yields " (tt "'#f") ".") (highlight scheme "(ck () (c-quote (c-u<= '(1 2) '(a b c))))\n;; ==> '#t\n(ck () (c-quote (c-u<= '(1 2 3) '(a b c))))\n;; ==> '#t\n(ck () (c-quote (c-u<= '(1 2 3 4) '(a b c))))\n;; ==> '#f"))
(def (sig (syntax "(c-u> U1 U2)  →  '#t or '#f" (id c-u>))) (p "Unary greater-than. Yields " (tt "'#t") " if the first list is longer than the second list, otherwise yields " (tt "'#f") ".") (highlight scheme "(ck () (c-quote (c-u> '(1 2 3 4) '(a b c))))\n;; ==> '#t\n(ck () (c-quote (c-u> '(1 2 3) '(a b c))))\n;; ==> '#f"))
(def (sig (syntax "(c-u>= U1 U2)  →  '#t or '#f" (id c-u>=))) (p "Unary greater-than-or-equals. Yields " (tt "'#t") " if first list is same length or longer than the second list, otherwise yields " (tt "'#f") ".") (highlight scheme "(ck () (c-quote (c-u>= '(1 2 3 4) '(a b c))))\n;; ==> '#t\n(ck () (c-quote (c-u>= '(1 2 3) '(a b c))))\n;; ==> '#t\n(ck () (c-quote (c-u>= '(1 2) '(a b c))))\n;; ==> '#f"))
(def (sig (syntax "(c-uzero? U)  →  '#t or '#f" (id c-uzero?))) (p "Unary " (tt "zero?") ". Yields " (tt "'#t") " if the list is empty, otherwise yields " (tt "'#f") ". Same as " (tt "c-null?") ".") (highlight scheme "(ck () (c-quote (c-uzero? '())))\n;; ==> '#t\n(ck () (c-quote (c-uzero? '(a))))\n;; ==> '#f"))
(def (sig (syntax "(c-ueven? U)  →  '#t or '#f" (id c-ueven?))) (p "Unary " (tt "even?") ". Yields " (tt "'#t") " if the given list's length is even (i.e. a multiple of 2), otherwise yields " (tt "'#f") ".") (highlight scheme "(ck () (c-quote (c-ueven? '())))\n;; ==> '#t\n(ck () (c-quote (c-ueven? '(a))))\n;; ==> '#f\n(ck () (c-quote (c-ueven? '(a b))))\n;; ==> '#t"))
(def (sig (syntax "(c-uodd? U)  →  '#t or '#f" (id c-uodd?))) (p "Unary " (tt "odd?") ". Yields " (tt "'#t") " if the given list's length is odd (i.e. not a multiple of 2), otherwise yields " (tt "'#f") ".") (highlight scheme "(ck () (c-quote (c-uodd? '())))\n;; ==> '#f\n(ck () (c-quote (c-uodd? '(a))))\n;; ==> '#t\n(ck () (c-quote (c-uodd? '(a b))))\n;; ==> '#f"))
(def (sig (syntax "(c-u+ U1 U2)  →  list" (id c-u+))) (p "Unary addition. Same as " (tt "c-append") ". This was named " (tt "c-add") " in the original implementation.") (highlight scheme "(ck () (c-quote (c-u+ '(a b) '(c))))\n;; ==> '(a b c)"))
(def (sig (syntax "(c-u- U1 U2)  →  list" (id c-u-))) (p "Unary subtraction. Drops an element from the front of the first list for each element in second list, then yields the remaining list. Negative numbers cannot be represented in unary, so this yields '() if the second list is equal or longer than the first.") (highlight scheme "(ck () (c-quote (c-u- (c-list 'a 'b 'c 'd) '(x y))))\n;; ==> '(c d)\n\n(ck () (c-quote (c-u- (c-list 'a 'b) (c-list 'x 'y 'z))))\n;; ==> '()\n;; Because negative numbers cannot be represented in unary."))
(def (sig (syntax "(c-u* U1 U2)  →  list" (id c-u*))) (p "Unary multiplication. Yields a list containing the contents of the first list, repeated once for every item in the second list.") (p "Based on " (tt "c-mul") " from the original implementation, except the symbol " (tt "'u") " has no special significance, and result is made from duplicating the first list.") (highlight scheme "(ck () (c-quote (c-u* '(a b) '(c d e))))\n;; ==> '(a b a b a b)"))
(def (sig (syntax "(c-u/ U1 U2)  →  (list list)" (id c-u/))) (p "Unary division. Yields a list of two unary numbers, representing the quotient and the remainder of the division.") (p "Given the second list has length " (tt "N") ", the quotient will contain every " (tt "N") "th item from the first list, and the remainder will contain the tail of the first list. Division by zero (empty list) is a syntax error.") (highlight scheme "(ck () (c-quote (c-u/ '(a b c d e f g h i j k)\n                      '(x y z))))\n;; ==> '((g d a) (j k))\n;; Because 11 / 3 = 3 with a remainder of 2."))
(def (sig (syntax "(c-ufactorial U)  →  list" (id c-ufactorial))) (p "Unary factorial. If the given list has length zero, yields the list " (tt "'(u)") ". If the given list has length one, yields the given list. Otherwise, yields a list containing items of the given list repeated " (tt "(N-1)!") " times, where " (tt "N") " is the length of the given list. This was named " (tt "c-fact") " in the original implementation.") (highlight scheme "(ck () (c-quote (c-ufactorial '(a b c))))\n;; ==> '(a b c a b c)\n;; Because 3! = 6."))
(def (sig (syntax "(c-udrop L U)  →  list" (id c-udrop))) (p "Drops up to U items from the front of the given list, where U is a unary number.") (p "Same as " (tt "c-u-") ". Analogous to " (tt "drop") " from SRFI 1, but uses unary numbers, and yields the empty list if the list is too short.") (highlight scheme "(ck () (c-quote (c-udrop (c-list 'a 'b 'c 'd) '(x y))))\n;; ==> '(c d)\n(ck () (c-quote (c-udrop (c-list 'a 'b) (c-list 'x 'y 'z))))\n;; ==> '()"))
(def (sig (syntax "(c-utake L U)  →  list" (id c-utake))) (p "Yields a list containing up to U items from the front of the given list, where U is a unary number.") (p "Analogous to " (tt "take") " from SRFI 1, but uses unary numbers, and yields the entire list if it is too short.") (highlight scheme "(ck () (c-quote (c-utake '(a b c d) '(x y z))))\n;; ==> '(a b c)\n(ck () (c-quote (c-utake '(a b) '(x y z))))\n;; ==> '(a b)"))
(def (sig (syntax "(c-dadd1 N)  →  'N+1 or '#f" (id c-dadd1))) (p "Add 1 to a decimal integer. If 0 <= N <= 15, yields N + 1. Otherwise yields " (tt "'#f") ". Added in " (b "version 0.3.0") ".") (highlight scheme "(ck () (c-dadd1 '0))\n;; ==> '1\n(ck () (c-dadd1 '15))\n;; ==> '16\n(ck () (c-dadd1 '16))\n;; ==> '#f") (p "The default domain is small because library compilation time increases rapidly the larger the domain is, because it generates a syntax-rules with many branches. You can define an " (tt "add1") " with a larger (or just different) domain using " (tt "c-make-next") " and a list of " (i "increasing") " integers:") (highlight scheme "(ck () `(define-syntax c-my-add1\n          ,(c-make-next '(-5 -4 -3 -2 -1 0 1 2 3 4 5))))"))
(def (sig (syntax "(c-dsub1 N)  →  'N-1 or '#f" (id c-dsub1))) (p "Subtract 1 from a decimal integer. If 1 <= N <= 16, yields N - 1. Otherwise yields " (tt "'#f") ". See the notes for " (tt "c-dadd1") ".") (highlight scheme "(ck () (c-dsub1 '16))\n;; ==> '15\n(ck () (c-dsub1 '1))\n;; ==> '0\n(ck () (c-dsub1 '0))\n;; ==> '#f") (p "As with " (tt "c-dadd1") ", you can define a " (tt "sub1") " with a larger (or just different) domain using " (tt "c-make-next") " and a list of " (i "decreasing") " integers:") (highlight scheme "(ck () `(define-syntax c-my-sub1\n          ,(c-make-next '(5 4 3 2 1 0 -1 -2 -3 -4 -5))))"))
(def (sig (syntax "(c-du N)  →  list or '#f" (id c-du)) (syntax "(c-du N '(SUB1 ...))  →  list or '#f" (id c-du))) (p "Convert from decimal integers to " (int-link "#unary-math" "unary integers") ". If N is in the domain of " (tt "SUB1") ", yields a list of that many elements, specifically the integers " (tt "(N-1, ..., 0)") ". Otherwise, yields " (tt "'#f") ".") (p (tt "SUB1") " is any operation that given N yields N-1, where 1 <= N. Defaults to " (tt "c-dsub1") ", which supports 1 <= N <= 16. See the note for " (tt "c-dsub1") " for how to make an operation with a larger domain.") (highlight scheme "(ck () (c-quote (c-du '0)))\n;; ==> '()\n(ck () (c-quote (c-du '16)))\n;; ==> '(15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0)\n(ck () (c-quote (c-du '17)))\n;; ==> '#f"))
(def (sig (syntax "(c-ud U)  →  integer or '#f" (id c-ud)) (syntax "(c-ud U '(ADD1 ...))  →  integer or '#f" (id c-ud))) (p "Convert from " (int-link "#unary-math" "unary integers") " to decimal integers. Given a list of items, yields the list's length as a decimal integer. The contents of the list do not matter, only its length. If the list length is too large for " (tt "ADD1") ", yields " (tt "'#f") ".") (p (tt "ADD1") " is any operation that given N yields N+1, where 0 <= N. Defaults to " (tt "c-dadd1") ", which supports 0 <= N <= 15. See the note for " (tt "c-dadd1") " for how to make an operation with a larger domain.") (highlight scheme "(ck () (c-ud '()))\n;; ==> '0\n(ck () (c-ud '(a b c d e f g h i j k l m n o p)))\n;; ==> '16\n(ck () (c-ud '(a b c d e f g h i j k l m n o p q)))\n;; ==> '#f"))
(def (sig (syntax "(c-eqv? X Y)  →  '#t or '#f" (id c-eqv?))) (p "CK-macro wrapper for " (tt "eqv?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-eq? X Y)  →  '#t or '#f" (id c-eq?))) (p "CK-macro wrapper for " (tt "eq?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-equal? X Y)  →  '#t or '#f" (id c-equal?))) (p "CK-macro wrapper for " (tt "equal?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-number? X)  →  '#t or '#f" (id c-number?))) (p "CK-macro wrapper for " (tt "number?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-integer? X)  →  '#t or '#f" (id c-integer?))) (p "CK-macro wrapper for " (tt "integer?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-= N ...)  →  '#t or '#f" (id c-=))) (p "CK-macro wrapper for " (tt "=") " (equal). Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-< N ...)  →  '#t or '#f" (id c-<))) (p "CK-macro wrapper for " (tt "<") " (less than). Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-> N ...)  →  '#t or '#f" (id c->))) (p "CK-macro wrapper for " (tt ">") " (greater than). Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-<= N ...)  →  '#t or '#f" (id c-<=))) (p "CK-macro wrapper for " (tt "<=") " (less than or equal). Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c->= N ...)  →  '#t or '#f" (id c->=))) (p "CK-macro wrapper for " (tt ">=") " (greater than or equal). Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-max N ...)  →  number" (id c-max))) (p "CK-macro wrapper for " (tt "max") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-min N ...)  →  number" (id c-min))) (p "CK-macro wrapper for " (tt "min") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-+ N ...)  →  number" (id c-+))) (p "CK-macro wrapper for " (tt "+") " (addition). Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-* N ...)  →  number" (id c-*))) (p "CK-macro wrapper for " (tt "*") " (multiplication). Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-- N ...)  →  number" (id c--))) (p "CK-macro wrapper for " (tt "-") " (subtraction). Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-/ N ...)  →  number" (id c-/))) (p "CK-macro wrapper for " (tt "/") " (division). Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-remainder N1 N2)  →  number" (id c-remainder))) (p "CK-macro wrapper for " (tt "remainder") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-floor N)  →  number" (id c-floor))) (p "CK-macro wrapper for " (tt "floor") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-round N)  →  number" (id c-round))) (p "CK-macro wrapper for " (tt "round") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-exact->inexact N)  →  inexact number" (id c-exact->inexact))) (p "CK-macro wrapper for " (tt "exact->inexact") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-inexact->exact N)  →  exact number" (id c-inexact->exact))) (p "CK-macro wrapper for " (tt "inexact->exact") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-number->string N)  →  string" (id c-number->string)) (syntax "(c-number->string N RADIX)  →  string" (id c-number->string))) (p "CK-macro wrapper for " (tt "number->string") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-string->number STR)  →  number or '#f" (id c-string->number)) (syntax "(c-string->number STR RADIX)  →  number or '#f" (id c-string->number))) (p "CK-macro wrapper for " (tt "string->number") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-length L)  →  integer" (id c-length))) (p "CK-macro wrapper for " (tt "length") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-list-ref L I)  →  item" (id c-list-ref))) (p "CK-macro wrapper for " (tt "list-ref") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-symbol? X)  →  '#t or '#f" (id c-symbol?))) (p "CK-macro wrapper for " (tt "symbol?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-symbol->string SYM)  →  string" (id c-symbol->string))) (p "CK-macro wrapper for " (tt "symbol->string") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-string->symbol STR)  →  symbol" (id c-string->symbol))) (p "CK-macro wrapper for " (tt "string->symbol") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-char? CHAR ...)  →  '#t or '#f" (id c-char?))) (p "CK-macro wrapper for " (tt "char?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-char=? CHAR ...)  →  '#t or '#f" (id c-char=?))) (p "CK-macro wrapper for " (tt "char=?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-string? X)  →  '#t or '#f" (id c-string?))) (p "CK-macro wrapper for " (tt "string?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-string CHAR ...)  →  string" (id c-string))) (p "CK-macro wrapper for " (tt "string") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-string-length STR)  →  integer" (id c-string-length))) (p "CK-macro wrapper for " (tt "string-length") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-string-ref STR I)  →  char" (id c-string-ref))) (p "CK-macro wrapper for " (tt "string-ref") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-string=? STR ...)  →  '#t or '#f" (id c-string=?))) (p "CK-macro wrapper for " (tt "string=?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-string-ci=? STR ...)  →  '#t or '#f" (id c-string-ci=?))) (p "CK-macro wrapper for " (tt "string-ci=?") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-substring STR START)  →  string" (id c-substring)) (syntax "(c-substring STR START END)  →  string" (id c-substring))) (p "CK-macro wrapper for " (tt "substring") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-string-append STR ...)  →  string" (id c-string-append))) (p "CK-macro wrapper for " (tt "string-append") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-vector-length V)  →  integer" (id c-vector-length))) (p "CK-macro wrapper for " (tt "vector-length") ". Added in " (b "version 0.2.0") "."))
(def (sig (syntax "(c-vector-ref V I)  →  item" (id c-vector-ref))) (p "CK-macro wrapper for " (tt "vector-ref") ". Added in " (b "version 0.2.0") "."))
