Re: Explain difference lists
- From: pineapple <pineapple.link@xxxxxxxxx>
- Date: Fri, 31 Jul 2009 16:13:01 -0700 (PDT)
On Aug 1, 5:36 am, Chip Eastham <hardm...@xxxxxxxxx> wrote:
Thanks for asking about an interesting topic that
I certainly have yet to master.
I played with the difference list append (1-liner) for quite a while:
append_dl(List1-Hole1,Hole1-Hole2,List1-Hole2).
% ?- append_dl([1,2,3|H1]-H1, [4,5]-H2, X).
% H1 = [4, 5],
% X = [1, 2, 3, 4, 5]-H2.
Upon first look (and even second and third) it appears to work by
"magic."
What none of these explanations tell you in all these books and web
pages is, the entire thing is done by "trick" and "sleight of hand."
The "trick" is that you are passing an argument in with an unbound
variable, and that exact unbound variable is "marked" within the hard-
coded predicate. Unification does all the "magic."
My first observation is, I believe the minus signs get in the way of
explaining what is going on, as does the word "difference."
My second observation is, they should throw the entire mathematical/
theoretical basis for this whole thing out the window when teaching
this in computer science, and teach it as the "trick" that it is. As
usual, the entire approach for describing and teaching this is utterly
wrong.
I recently was hired to make sense of a set of instructions for doing
a particular task. The instructions were several pages in length.
Nobody knew how to use them or make sense of them. After careful
study, I didn't either. I took the whole thing to an "expert" who
told me the real deal. I then threw the instructions into the
garbage, and wrote new ones for the people who hired me. My
instructions were just a couple of lines long, easily followed and
understood by all who looked at them.
.
- Follow-Ups:
- Re: Explain difference lists
- From: pineapple
- Re: Explain difference lists
- References:
- Re: Explain difference lists
- From: Chip Eastham
- Re: Explain difference lists
- Prev by Date: Re: Explain difference lists
- Next by Date: Re: Explain difference lists
- Previous by thread: Re: Explain difference lists
- Next by thread: Re: Explain difference lists
- Index(es):
Relevant Pages
|