FB18 - Das Forum für Informatik

fb18.de / Diplom Informatik / Unterbereich Grundstudium / Praktische Informatik

SWI Prolog und length

SWI Prolog und length 2002-01-02 12:05
Popcorn
?- length(X, [a,b,c]).
ERROR: length/2: Type error: `integer' expected, found `[a, b, c]'

Eigentlich sollte da ja X=3 rauskommen. Normal?

Re: SWI Prolog und length 2002-01-02 12:15
Zaphod
nicht weiter schwer: Du hast die Parameter vertauscht!
?- length([a,b,c],X).
X=3
yes

Re: SWI Prolog und length 2002-01-02 12:16
Popcorn
Ah ja. Danke für das Selbstgespräch [img]http://images.rapidforum.com/images/i15.gif[/img].
Slide 15 auf Seite 109 im Skript suckt. Darüber ist es noch richtig, aber dann steht dort "length(X,[a,b,c])." was besser
hätte "length([a,b,c],X)." heißen sollen. *Seufz*

Nachtrag: Das zum Thema zeitgleiches posten @ Zaphod.

Re: SWI Prolog und length 2002-01-02 17:01
P0rnopeters
*aargh*!
an der stelle bin ich auch fast wahnsinnig geworden! warum steht der scheiss auch verkehrtrum im skript!?! [img]http://images.rapidforum.com/images/i19.gif[/img](