wip
This commit is contained in:
parent
fbdc710918
commit
7bbf3a5070
5 changed files with 57 additions and 1 deletions
7
ack.rkt
Normal file
7
ack.rkt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
;; The first three lines of this file were inserted by DrRacket. They record metadata
|
||||
;; about the language level of this file in a form that our tools can easily process.
|
||||
#reader(lib "htdp-advanced-reader.ss" "lang")((modname ack) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f () #f)))
|
||||
(define (ack n m)
|
||||
(cond [(= 0 n) (+ m 1)]
|
||||
[(= 0 m) (ack (- n 1) 1)]
|
||||
[else (ack (- n 1) (ack n (- m 1)))]))
|
||||
5
bst.rkt
5
bst.rkt
|
|
@ -109,3 +109,8 @@
|
|||
[(empty? (node-left node)) (node-right node)]
|
||||
[(empty? (node-right node)) (node-left node)]
|
||||
[else (make-node (node-value (replacement node)) (sans-max-subtree (node-left node)) (node-right node))]))
|
||||
|
||||
(check-equal? (delete empty) empty)
|
||||
(check-equal? (delete (make-node 5 empty empty)) empty)
|
||||
(check-equal? (make-node 5 empty empty) (make-node 5 empty empty))
|
||||
(check-equal? (delete (make-node 6 (make-node 2 empty empty) empty)) (make-node 2 empty empty))
|
||||
20
fop-klausur.rkt
Normal file
20
fop-klausur.rkt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
;; The first three lines of this file were inserted by DrRacket. They record metadata
|
||||
;; about the language level of this file in a form that our tools can easily process.
|
||||
#reader(lib "htdp-advanced-reader.ss" "lang")((modname fop-klausur) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f () #f)))
|
||||
(define-struct abc (a b))
|
||||
|
||||
(define (foo p)
|
||||
(if (abc? p)
|
||||
(if (list? (abc-b p))
|
||||
(cons (abc-a p) (abc-b p))
|
||||
empty)
|
||||
empty))
|
||||
|
||||
(define (bar lst n)
|
||||
(cond
|
||||
[(= 0 n) empty]
|
||||
[(< (length lst) n) lst]
|
||||
[else (cons (first lst) (bar (rest lst) (- n 1)))]))
|
||||
|
||||
(define (foo-bar n)
|
||||
(lambda (x) (bar x n)))
|
||||
10
pascal-line.rkt
Normal file
10
pascal-line.rkt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
;; The first three lines of this file were inserted by DrRacket. They record metadata
|
||||
;; about the language level of this file in a form that our tools can easily process.
|
||||
#reader(lib "htdp-advanced-reader.ss" "lang")((modname pascal-line) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f () #f)))
|
||||
(define (pascal-line n)
|
||||
(cond [(= n 0) (list 1)]
|
||||
[else (new-pascal-line (append (list 0) (pascal-line (- n 1)) (list 0)))]))
|
||||
|
||||
(define (new-pascal-line l)
|
||||
(cond [(< (length l) 2) empty]
|
||||
[else (cons (+ (first l) (second l)) (new-pascal-line (rest l)))]))
|
||||
14
substr.rkt
Normal file
14
substr.rkt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
;; The first three lines of this file were inserted by DrRacket. They record metadata
|
||||
;; about the language level of this file in a form that our tools can easily process.
|
||||
#reader(lib "htdp-advanced-reader.ss" "lang")((modname substr) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f () #f)))
|
||||
(define (is-substring? s sub)
|
||||
(is-substring-expl? (explode s) (explode sub) (explode sub)))
|
||||
|
||||
(define (is-substring-expl? s sub backup)
|
||||
(cond [(empty? sub) #t]
|
||||
[(empty? s) #f]
|
||||
[(equal? (first s) (first sub))
|
||||
(is-substring-expl? (rest s) (rest sub) backup)]
|
||||
[(equal? (first s) (first backup))
|
||||
(is-substring-expl? (rest s) (rest backup) backup)]
|
||||
[else (is-substring-expl? (rest s) sub backup)]))
|
||||
Loading…
Add table
Add a link
Reference in a new issue