Common Lisp Assoziationslisten

Discussion of Common Lisp
Post Reply
Oneida02
Posts: 1
Joined: Tue Jul 01, 2014 11:18 am

Common Lisp Assoziationslisten

Post by Oneida02 » Tue Jul 01, 2014 11:21 am

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?

Goheeca
Posts: 271
Joined: Thu May 10, 2012 12:54 pm
Contact:

Re: Common Lisp Assoziationslisten

Post by Goheeca » Thu Jul 03, 2014 9:58 am

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.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

edgar-rft
Posts: 226
Joined: Fri Aug 06, 2010 6:34 am
Location: Germany

Re: Common Lisp Assoziationslisten

Post by edgar-rft » Sat Jul 05, 2014 3:08 am

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.

Post Reply