Date of registration: Dec 11th 2001
Location: Hämelerwald
Occupation: Wissenschaftlicher Mitarbeiter (Forschungszentrum L3S, TU Braunschweig)
Zwei Fehler:
Quoted
Original von SantaBlock
Wer kann mir helfen?
Mein Prorgramm sieht wie folgt aus:
(define (tribo-list n)
(if (< n 0) n
(cons (tribo n) (tribo-list (- n 1)))))
(tribo-list 10) liefert bei mir (81 44 24 13 7 4 2 1 1 0 0 . -1)
Wie schaffe ich es nun nur (81 44 24 13 7 4 2 1 1 0 0) zu erhalten?
Date of registration: Oct 17th 2003
Location: Dresden
Occupation: Um ein bißchen mehr Ahnung zu haben als andere
![]() |
Source code |
1 2 3 4 5 6 7 8 9 |
(define (iterator start next end?) (define (i-innen cur n) ( if (end? cur n) cur (i-innen (next cur (+ n 1)) ) ) ) (i-innen start 0) ) |
Date of registration: Oct 17th 2003
Location: Dresden
Occupation: Um ein bißchen mehr Ahnung zu haben als andere
This post has been edited 2 times, last edit by "Lucky" (Nov 25th 2004, 2:50pm)
Date of registration: Dec 11th 2001
Location: Hämelerwald
Occupation: Wissenschaftlicher Mitarbeiter (Forschungszentrum L3S, TU Braunschweig)
list-ref
Quoted
Original von Lucky
Man hat eine Liste (define list ("Hallo" "Toll" "Schoen" "Scheisse"))
Und ich möchte das Wort an der 3. Stelle haben, OHNE car und cdr Befehle.
Also quasi: Wie komme ich an die n-te Stelle einer Liste ran???
list-tail
Quoted
Es würde auch gehen, wenn ich wüsste, wie ich das erste Wort einer liste, an das ich mit car rangekommen bin, löschen könnte!
This post has been edited 1 times, last edit by "Joachim" (Nov 25th 2004, 2:51pm)
Date of registration: Oct 17th 2003
Location: Dresden
Occupation: Um ein bißchen mehr Ahnung zu haben als andere
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
(define (spell-char char spell-list) (define (iteratorhilfe char1 spell-list1 n) (if (= n (length spell-list1)) "scheisse" (if (eq? (string-ref (list-ref spell-list1 n) 0) char) (list-ref spell-list1 n) (iteratorhilfe char1 spell-list1 (+ n 1))) ) ) (iteratorhilfe char spell-list 0)) (spell-char "ENGEL" (list "Einfuehlsam" "Goettlich" "Liebevoll" "Niedlich")) |
This post has been edited 3 times, last edit by "Lucky" (Nov 25th 2004, 9:46pm)
Date of registration: Dec 11th 2001
Location: Hämelerwald
Occupation: Wissenschaftlicher Mitarbeiter (Forschungszentrum L3S, TU Braunschweig)
Gleich drei Fehler:
Quoted
Original von Lucky
Diese Funktion gibt bei mir scheisse aus, obwohl er doch Einfuehlsam ausgeben müsste!
Date of registration: Oct 17th 2003
Location: Dresden
Occupation: Um ein bißchen mehr Ahnung zu haben als andere
This post has been edited 1 times, last edit by "Lucky" (Nov 25th 2004, 10:16pm)
This post has been edited 1 times, last edit by "iriania" (Nov 25th 2004, 10:39pm)
This post has been edited 1 times, last edit by "iriania" (Nov 25th 2004, 10:36pm)
Date of registration: Oct 17th 2003
Location: Dresden
Occupation: Um ein bißchen mehr Ahnung zu haben als andere
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Alte: (define (popsim p0 g n) (define (popsim-iter ergebnis n) ( if (= n 0) ergebnis (popsim-iter (+ ergebnis (* (* g ergebnis) (- 1 ergebnis))) (- n 1) ) )) (popsim-iter p0 g n) ) Neue auf iterator basierend: (define (popsim po g nmax) (iterator po (lambda (cur n) (+ cur (* (* g cur) (- 1 cur))) ) (lambda (cur n) (= n nmax) ) )) |