P1: mylength / append
2005-02-07 01:55
Anonymer User
Hi!
Hab zwei Fragen:
Einmal, kann mir jemand anhand eines traces zeigen wie genau das N is N1+1 im Prädikat mylength/2 funktioniert?
mylength([ ],0).
mylength([_|Rest],N) :-
mylength(Rest,N1),
N is N1+1
Und zum zweiten, anhand ein traces wie das genau funktioniert mit dem Kopf abziehen beim Prädikat append/3:
app([ ],L,L).
app([Kopf|Rest1],L2,[Kopf|ZR]) :-
app(Rest1,L2,ZR)
Danke!
(edit: Topictitel – fal)
Hab zwei Fragen:
Einmal, kann mir jemand anhand eines traces zeigen wie genau das N is N1+1 im Prädikat mylength/2 funktioniert?
mylength([ ],0).
mylength([_|Rest],N) :-
mylength(Rest,N1),
N is N1+1
Und zum zweiten, anhand ein traces wie das genau funktioniert mit dem Kopf abziehen beim Prädikat append/3:
app([ ],L,L).
app([Kopf|Rest1],L2,[Kopf|ZR]) :-
app(Rest1,L2,ZR)
Danke!
(edit: Topictitel – fal)