From: Rob Thorpe
Subject: Re: Ray tracer in Stalin
Date: 
Message-ID: <1124473638.914242.9930@f14g2000cwb.googlegroups.com>
Marco Antoniotti wrote:
> Matthias Buelow wrote:
> > F?rster vom Silberwald <··········@hotmail.com> wrote:
> >
> > [...]
> >
> >
> >>a) Man must believe in God
> >>c) The Scheme language
> >>standard is a beauty in itslef.
> >
> >
> >>  (map2e::obj fun::obj lis1::pair-nil lis2::pair-nil)
> >>  (match-case (list lis2 lis2)
> >>     [(() ()) '()]
> >>     [((?h1 ???t1) (?h2 ???t2))
> >
> >
> > Are you being ironic? The above doesn't even look very much like
> > Scheme anymore, let alone "beautyful"..
>
> But the following looks very much like Common Lisp
>
>
> (use-package "UNIFY")
>
> (defun map2 (fun list-1 list-2)
>     (match-case (list list-1 list-2)
>        ((() ()) ())
>        (((?h1 . ?t1) (?h2 . ?t2))
>         (cons (funcall fun h1 h2) (map2 fun t1 t2)))
>        ((_ _) (error "Invalid list arguments to map2: ~S ~S." list-1
> list-2)))
>
> Not only it looks like Common Lisp.  It is written in Common Lisp and it
> runs on every decent Common Lisp system.
>
> http://common-lisp.net/project/cl-unification

To me that looks fairly horrible.  I would at least put spaces in the
first case, ie

(defun map2 (fun list-1 list-2)
    (match-case (list list-1 list-2)
       (( () () ) () )
       (((?h1 . ?t1) (?h2 . ?t2))
        (cons (funcall fun h1 h2) (map2 fun t1 t2)))
       ((_ _) (error "Invalid list arguments to map2: ~S ~S." list-1
list-2)))

In fact, is the first case right.

From: Marco Antoniotti
Subject: CL UNIFICATION (Re: Ray tracer in Stalin)
Date: 
Message-ID: <siqNe.52$DJ5.69369@typhoon.nyu.edu>
Rob Thorpe wrote:
> Marco Antoniotti wrote:

>>
>>(use-package "UNIFY")
>>
>>(defun map2 (fun list-1 list-2)
>>    (match-case (list list-1 list-2)
>>       ((() ()) ())
>>       (((?h1 . ?t1) (?h2 . ?t2))
>>        (cons (funcall fun h1 h2) (map2 fun t1 t2)))
>>       ((_ _) (error "Invalid list arguments to map2: ~S ~S." list-1
>>list-2)))
>>
>>Not only it looks like Common Lisp.  It is written in Common Lisp and it
>>runs on every decent Common Lisp system.
>>
>>http://common-lisp.net/project/cl-unification
> 
> 
> To me that looks fairly horrible.  I would at least put spaces in the
> first case

Well. It is kind of ugly :)  But that was not the point of the UNIFY 
package.  The point was to have a full blown unification system for 
Common Lisp; not to have optimal syntax for these kind of operations. 
Once you have UNIFY, then you can start experimenting with the various 
extensions.  E.g. the above could also be written as

	(defun map2 (fun l1 l2)
	   (match-ecase (list l1 l2)
              (#T(list () ())
               ())
	     (#T(list #T(list ?h1 &rest ?t2) #T(list ?h2 &rest ?t2))
	      (cons (funcall fun h1 h2) (map2 fun t1 t2)))))

The #T reader macro is used to denote "templates".

Have a look at the docs (http://common-lisp.net/projects/cl-unification) 
and punch holes in the system.  It will get better that way.


Cheers
--
Marco
From: Jon Harrop
Subject: Re: Ray tracer in Stalin
Date: 
Message-ID: <43062378$0$1300$ed2619ec@ptn-nntp-reader02.plus.net>
Rob Thorpe wrote:
> (defun map2 (fun list-1 list-2)
>     (match-case (list list-1 list-2)
>        (( () () ) () )
>        (((?h1 . ?t1) (?h2 . ?t2))
>         (cons (funcall fun h1 h2) (map2 fun t1 t2)))
>        ((_ _) (error "Invalid list arguments to map2: ~S ~S." list-1
> list-2)))
> 
> In fact, is the first case right.

Apparently you don't need to count parentheses when writing "((()())())" so
I wouldn't worry about it. ;-)

-- 
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com