Dies ist eine statische Kopie unseres alten Forums. Es sind keine Interaktionen möglich.
This is a static copy of our old forum. Interactions are not possible.

BlaueMotte

Trainee

  • "BlaueMotte" is female
  • "BlaueMotte" started this thread

Posts: 76

Date of registration: Apr 9th 2002

Location: vom platten Land mit Nordseeluft

Occupation: hä? Studi...

1

Thursday, January 23rd 2003, 5:24pm

Scheme, 11. Übungsblatt

Hallo, sitze gerade an der 2. Aufgabe von Scheme. Verstehe nur nicht ganz genau, wie ich aus 3 cons beim Aufruf 7 erhalten soll. Glaube, ich muss mittels set-car! oder set-cdr! den Zeigen umsetzen, aber wie? Wie kann ich ihn wieder auf sich selbst legen?

Und ist sowas okay?
(define y (cons 1 (cons 2 (cons 3 4))))
y
(set-cdr! y y)
y
(paar-zaehler y) ;->es kommt nie zu einem Ergebnis - Ringstruktur!

Macht noch jemand Scheme und kann mir Tipps geben?

Danke!

BlaueMotte

HoloMaD

Trainee

  • "HoloMaD" is male

Posts: 115

Date of registration: Oct 5th 2002

Location: Hannover (Nordstadt)

2

Friday, January 24th 2003, 11:04am

Das is doch einfach:
[ | ]<-z
| |
v v
[ | ]<-y
| |
v v
[/|/]<-x

(define x (cons '() '())
(define y (cons x x))
(define z (cons y y)

ende:)
cu
HoloMaD
We purposely trained him wrong, as a joke.

BlaueMotte

Trainee

  • "BlaueMotte" is female
  • "BlaueMotte" started this thread

Posts: 76

Date of registration: Apr 9th 2002

Location: vom platten Land mit Nordseeluft

Occupation: hä? Studi...

3

Friday, January 24th 2003, 1:09pm

Danke für die Antwort. Mittlerweile war ich auch drauf gekommen...