Thanks Alex. So, a better description of diff might be "Returns all the elements in the first argument that are not in the second argument"?

On Sun, Nov 27, 2016 at 2:45 AM, Alexander Burger <a...@software-lab.de> wrote: > On Sat, Nov 26, 2016 at 09:05:44PM -0500, Bruno Franco wrote: > > I was trying out the diff function and I noticed something: > > > > : (diff '(1 2 3 4) '(3 4)) > > -> (1 2) > > > > but > > > > : (diff '(3 4) '(1 2 3 4)) > > -> NIL > > > > I think this means that there is an order to the arguments of diff, where > > It is analogous to the arithmetic difference, where A - B is not the > same as B - A. > > > > the second argument must be the shortest. > > This is not the case. The length is not relevant: > > : (diff (1 2 3) (8 6 4 2)) > -> (1 3) > > > > I also tried this: > > > > : (diff (1 2 3 4) 2) > > -> (1 3 4) > > > > So, why does diff work even if the second argument isn't a list? > > This is a result of how 'diff' is implemented internally. It takes all > elements into account, I think it is a welcome feature. Note that this > also works: > > : (diff (1 2 3) (1 . 2)) > -> (3) > > ♪♫ Alex > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >