Page 1 of 1

Common Lisp Assoziationslisten

Posted: Tue Jul 01, 2014 11:21 am
by Oneida02
Folgende Aufgabe:
Definieren Sie in einer Funktion eine Assoziationsliste BAUTEILE, die zu den Assoziationsbegriffen
WASSER und LUFT mindestens jeweils drei Atome enthält. Die gesamte Assoziationsliste soll auf dem
Bildschirm ausgegeben werden (alert).

Mein Programm:


(defun c:test() ; defun = Deklaration der Funktion test c steht für command, so muss beim Aufrufen der Funktion keine Klammern eingegeben werden
(setq Temperatur 55) ; Deklaration der Listenvariablen von Wasser
(setq Siedepunkt 100)
(setq Gefrierpunkt 0)

(setq Sauerstoffgehalt 20) ; Deklaration der Listenvariablen von LUFT
(setq Dichte 1)
(setq Druck 101)

(setq WASSER (cons Temperatur(cons Siedepunkt( cons Gefrierpunkt()))))
(setq LUFT(cons Sauerstoffgehalt(cons Dichte(cons Druck()))))
(list WASSER LUFT) ; Liste mit Wasser und LUFT erstellen
(setq BAUTEILE (WASSER LUFT)) ; Liste Bauteile zusammensetzen aus WASSER und LUFT



(alert(assoc LUFT BAUTEILE(assoc WASSER BAUTEILE))) ; Gibt ein Nachrichtenfenster aus mit der Assoziationsliste BAUTEILE
)

-------------------------------------
Fehler: Fehlerhafte Funktion. Ich finde den Fehler nicht, könnte mir jemand einen Denkanstoß geben?

Re: Common Lisp Assoziationslisten

Posted: Thu Jul 03, 2014 9:58 am
by Goheeca
What kind of environment are you using? alert isn't part of CLHS, what is the package named c?

The way of defining a function c:test outside of its package is very unusual. Using setq for undefined variables has undefined consequences, because the global variables should be/are set always special (that does defvar,defparameter, etc.), which setq simply doesn't do -- it defines a variable like defvar, but doesn't make it special as defvar in some CL implementations.

Moreover, the assoc is used in a strange way (not compatible with CL). What are you exactly trying to achieve? Can you describe your problem unambiguously? I can't grasp it from your code. Perhaps, decompose it to subproblems and ask them separately.

Re: Common Lisp Assoziationslisten

Posted: Sat Jul 05, 2014 3:08 am
by edgar-rft
German: In diesem Teil des Forums geht es um Common Lisp, AutoLisp Fragen bitte unter Other Dialects stellen. Fast niemand spricht hier deutsch, deshalb die Fragen am besten in englisch stellen. Ich selber habe kein AutoCAD, deshalb kann ich auch nicht viel helfen.

English: This section of the forum is about Common Lisp. Please ask AutoLisp questions in the Other Dialects section. Nearly nobody here speaks German, so it's better to ask questions in English. I myself can't help much because I don't have AutoCAD.