Path: utzoo!attcan!uunet!wuarchive!uwm.edu!ux1.cso.uiuc.edu!iuvax!copper!raja From: raja@copper.ucs.indiana.edu (Raja Sooriamurthi) Newsgroups: comp.lang.lisp Subject: Re: Mirror speeds Message-ID: Date: 13 Oct 90 21:21:27 GMT References: <47064@cornell.UUCP> Sender: news@iuvax.cs.indiana.edu Distribution: comp Lines: 34 wilk@fife.cs.cornell.edu (Michael Wilk) writes: > Here are some timing results on suggested solutions for the "mirror" > function: I won't reveal the huge list I tried this on, but trust me: > It was big. [stats. deleted] Here is a CPSed form of the mirror function. Now all calls to the auxillary function mir are properly tail recursive and a scheme implementation (and some CL implementations) would optimize the recursive calls into jumps. Just out of curiosity I'd like to see how this version compares with the other ones. The code below is in Scheme where in I've used scheme's equivalent of the Y combinator, rec, to define mir. Could you convert this into Common Lisp and run it on your data set. - Raja raja@cs.indiana.edu (define mirror/k (lambda (l) ((rec mir (lambda (l k) (cond [(atom? l) (k l)] [else (mir (car l) (lambda (a) (mir (cdr l) (lambda (d) (k (append d (list a)))))))]))) l (lambda (v) v))))