added gensym, current-millisecond, sleep, assoc, with-i/o-from-to

svn: r17444
This commit is contained in:
Matthias Felleisen 2009-12-30 22:45:12 +00:00
parent fb9a71d5a7
commit 5296a0a877

View File

@ -1,78 +1,94 @@
(module advanced-funs scheme/base
(require "teachprims.ss"
mzlib/etc
mzlib/list
mzlib/pretty
syntax/docprovide
mzlib/etc
mzlib/list
mzlib/pretty
syntax/docprovide
scheme/promise
"../posn.ss"
"../posn.ss"
(for-syntax scheme/base))
(provide-and-document
procedures
("Reading and Printing"
(print (any -> void)
"to print the argument as a value to stdout")
"to print the argument as a value to stdout")
(display (any -> void)
"to print the argument to stdout (without quotes on symbols and strings, etc.)")
"to print the argument to stdout (without quotes on symbols and strings, etc.)")
(write (any -> void)
"to print the argument to stdout (in a traditional style that is somewhere between print and display)")
"to print the argument to stdout (in a traditional style that is somewhere between print and display)")
(pretty-print (any -> void)
"like write, but with standard newlines and indentation")
"like write, but with standard newlines and indentation")
(printf (string any ... -> void)
"to format the rest of the arguments according to the first argument and print it to stdout")
"to format the rest of the arguments according to the first argument and print it to stdout")
(newline (-> void)
"to print a newline to stdout")
"to print a newline to stdout")
(read (-> sexp) "to read input from the user"))
("Lists"
(list? (any -> boolean)
"to determine whether some value is a list")
(list? (any -> boolean)
"to determine whether some value is a list")
((advanced-list* list*) (any ... (listof any) -> (listof any))
"to construct a list by adding multiple items to a list")
"to construct a list by adding multiple items to a list")
((advanced-cons cons) (X (listof X) -> (listof X))
"to construct a list")
"to construct a list")
((advanced-append append) ((listof any) ... -> (listof any))
"to create a single list from several"))
"to create a single list from several")
(assoc
(any (listof any) -> (listof any) or false)
"to produce the first element on the list whose first is equal? to v; otherwise it produces false"))
("Misc"
(random (-> (and/c real? inexact? (>/c 0) (</c 1)))
"to generate a random number between 0 and 1 (excl).")
(random (-> (and/c real inexact? (>/c 0) (</c 1)))
"to generate a random number between 0 and 1 (excl).")
(gensym (-> symbol?)
"to generate a new symbol, different from all symbols in the program")
(sleep (-> positive-number void)
"to cause the program to sleep for the given number of seconds")
(current-milliseconds (-> exact-integer)
"to return the current “time” in fixnum milliseconds (possibly negative)")
(with-input-from-file (string (-> any) -> any)
"to open the given string as an input file and to make it the current input port")
(with-output-to-file (string (-> any) -> any)
"to open the given string as an output file and to make it the current output port")
(force (delay -> any) "to find the delayed value; see also delay")
(promise? (any -> boolean) "to determine if a value is delayed")
(void (-> void) "produces a void value")
(void? (any -> boolean) "to determine if a value is void"))
("Posns"
(set-posn-x! (posn number -> void) "to update the x component of a posn")
(set-posn-y! (posn number -> void) "to update the x component of a posn"))
("Vectors"
(vector (X ... -> (vector X ...))
"to construct a vector")
"to construct a vector")
(make-vector (number X -> (vectorof X))
"to construct a vector")
"to construct a vector")
(build-vector (nat (nat -> X) -> (vectorof X))
"to construct a vector")
"to construct a vector")
(vector-ref ((vector X) nat -> X)
"to extract an element from a vector")
"to extract an element from a vector")
(vector-length ((vector X) -> nat)
"to determine the length of a vector")
"to determine the length of a vector")
(vector-set! ((vectorof X) nat X -> void)
"to update a vector")
"to update a vector")
(vector? (any -> boolean)
"to determine if a value is a vector"))
"to determine if a value is a vector"))
("Boxes"
(box (any -> box)
"to construct a box")
"to construct a box")
(unbox (box -> any)
"to extract the boxed value")
"to extract the boxed value")
(set-box! (box any -> void)
"to update a box")
"to update a box")
(box? (any -> boolean)
"to determine if a value is a box"))))
"to determine if a value is a box"))))