fix name of sort function in htdp languages
svn: r11193
This commit is contained in:
parent
57d33070f9
commit
23edcfc129
|
@ -26,7 +26,7 @@
|
||||||
"(build-string n f) = (string (f 0) ... (f (- n 1)))")
|
"(build-string n f) = (string (f 0) ... (f (- n 1)))")
|
||||||
((intermediate-quicksort quicksort) ((listof X) (X X -> boolean) -> (listof X))
|
((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")
|
"to construct a list from all items on a list in an order according to a predicate")
|
||||||
((intermediate-quicksort sort) ((listof X) (X X -> boolean) -> (listof X))
|
((intermediate-sort sort) ((listof X) (X X -> boolean) -> (listof X))
|
||||||
"to construct a list from all items on a list in an order according to a predicate")
|
"to construct a list from all items on a list in an order according to a predicate")
|
||||||
(andmap ((X -> boolean) (listof X) -> boolean)
|
(andmap ((X -> boolean) (listof X) -> boolean)
|
||||||
"(andmap p (list x-1 ... x-n)) = (and (p x-1) (and ... (p x-n)))")
|
"(andmap p (list x-1 ... x-n)) = (and (p x-1) (and ... (p x-n)))")
|
||||||
|
|
|
@ -281,17 +281,24 @@ namespace.
|
||||||
(string-append (format "~a : " quicksort) (apply format fmt-str x))
|
(string-append (format "~a : " quicksort) (apply format fmt-str x))
|
||||||
(current-continuation-marks))))
|
(current-continuation-marks))))
|
||||||
|
|
||||||
(define-teach intermediate quicksort
|
(define (do-sort l cmp? name)
|
||||||
(lambda (l cmp?)
|
|
||||||
(unless (beginner-list? l)
|
(unless (beginner-list? l)
|
||||||
(qcheck 'quicksort "first argument must be of type <list>, given ~e" l))
|
(qcheck name "first argument must be of type <list>, given ~e" l))
|
||||||
(unless (and (procedure? cmp?) (procedure-arity-includes? cmp? 2))
|
(unless (and (procedure? cmp?) (procedure-arity-includes? cmp? 2))
|
||||||
(qcheck 'quicksort "second argument must be a <procedure> that accepts two arguments, given ~e" cmp?))
|
(qcheck name "second argument must be a <procedure> that accepts two arguments, given ~e" cmp?))
|
||||||
(quicksort l (lambda (x y)
|
(sort l (lambda (x y)
|
||||||
(define r (cmp? x y))
|
(define r (cmp? x y))
|
||||||
(unless (boolean? r)
|
(unless (boolean? r)
|
||||||
(qcheck 'quicksort "the results of the procedure argument must be of type <boolean>, produced ~e" r))
|
(qcheck name "the results of the procedure argument must be of type <boolean>, produced ~e" r))
|
||||||
r))))
|
r)))
|
||||||
|
|
||||||
|
(define-teach intermediate quicksort
|
||||||
|
(lambda (l cmp?)
|
||||||
|
(do-sort l cmp? 'quicksort)))
|
||||||
|
(define-teach intermediate sort
|
||||||
|
(lambda (l cmp?)
|
||||||
|
(do-sort l cmp? 'sort)))
|
||||||
|
|
||||||
(define-teach intermediate foldr
|
(define-teach intermediate foldr
|
||||||
(lambda (f e l)
|
(lambda (f e l)
|
||||||
(unless (and (procedure? f) (procedure-arity-includes? f 2))
|
(unless (and (procedure? f) (procedure-arity-includes? f 2))
|
||||||
|
@ -356,6 +363,7 @@ namespace.
|
||||||
beginner-equal~?
|
beginner-equal~?
|
||||||
beginner-=~
|
beginner-=~
|
||||||
intermediate-quicksort
|
intermediate-quicksort
|
||||||
|
intermediate-sort
|
||||||
intermediate-foldr
|
intermediate-foldr
|
||||||
intermediate-foldl
|
intermediate-foldl
|
||||||
intermediate-build-string
|
intermediate-build-string
|
||||||
|
|
Loading…
Reference in New Issue
Block a user