racket/collects/lang/htdp-intermediate.ss
Matthew Flatt 39cedb62ed v3.99.0.2
svn: r7706
2007-11-13 12:40:00 +00:00

81 lines
3.4 KiB
Scheme

(module htdp-intermediate scheme/base
(require "private/teach.ss"
"private/teachprims.ss"
"private/contract-forms.ss"
mzlib/etc
mzlib/list
syntax/docprovide)
;; syntax:
(provide (rename-out
[intermediate-define define]
[intermediate-define-struct define-struct]
[beginner-lambda lambda]
[intermediate-app #%app]
[beginner-top #%top]
[intermediate-local local]
[intermediate-let let]
[intermediate-let* let*]
[intermediate-letrec letrec]
;; [intermediate-recur recur]
[beginner-cond cond]
[beginner-else else]
[beginner-if if]
[beginner-and and]
[beginner-or or]
[beginner-require require]
[beginner-dots ..]
[beginner-dots ...]
[beginner-dots ....]
[beginner-dots .....]
[beginner-dots ......]
[intermediate-quote quote]
[intermediate-quasiquote quasiquote]
[intermediate-unquote unquote]
[intermediate-unquote-splicing unquote-splicing]
[intermediate-time time]
[intermediate-module-begin #%module-begin]
;; [intermediate-contract contract]
;; [intermediate-define-data define-data]
)
#%datum
#%top-interaction
empty true false)
;; procedures:
(provide-and-document
procedures
(all-from beginner: lang/private/beginner-funs procedures)
("Higher-Order Functions"
(map ((X ... -> Z) (listof X) ... -> (listof Z))
"to construct a new list by applying a function to each item on one or more existing lists")
(for-each ((any ... -> any) (listof any) ... -> void)
"to apply a function to each item on one or more lists for effect only")
(filter ((X -> boolean) (listof X) -> (listof X))
"to construct a list from all those items on a list for which the predicate holds")
((intermediate-foldr foldr) ((X Y -> Y) Y (listof X) -> Y)
"(foldr f base (list x-1 ... x-n)) = (f x-1 ... (f x-n base))")
((intermediate-foldl foldl) ((X Y -> Y) Y (listof X) -> Y)
"(foldl f base (list x-1 ... x-n)) = (f x-n ... (f x-1 base))")
(build-list (nat (nat -> X) -> (listof X))
"(build-list n f) = (list (f 0) ... (f (- n 1)))")
((intermediate-build-string build-string) (nat (nat -> char) -> string)
"(build-string n f) = (string (f 0) ... (f (- n 1)))")
((intermediate-quicksort quicksort) ((listof X) (X X -> boolean) -> (listof X))
"to construct a list from all items on a list in an order according to a predicate")
(andmap ((X -> boolean) (listof X) -> boolean)
"(andmap p (list x-1 ... x-n)) = (and (p x-1) (and ... (p x-n)))")
(ormap ((X -> boolean) (listof X) -> boolean)
"(ormap p (list x-1 ... x-n)) = (or (p x-1) (or ... (p x-n)))")
(memf ((X -> boolean) (listof X) -> (union false (listof X)))
"to determine whether the first argument produces true for some value in the second argument")
(apply ((X-1 ... X-N -> Y) X-1 ... X-i (list X-i+1 ... X-N) -> Y)
"to apply a function using items from a list as the arguments")
(compose ((Y-1 -> Z) ... (Y-N -> Y-N-1) (X-1 ... X-N -> Y-N) -> (X-1 ... X-N -> Z))
"to compose a sequence of procedures into a single procedure")
(procedure? (any -> boolean)
"to determine if a value is a procedure"))))