Re: Newbie Design Question

From: Kenny Tilton (ktilton_at_nyc.rr.com)
Date: 11/23/03


Date: Sun, 23 Nov 2003 16:54:46 GMT


Jeff Katcher wrote:

> I'm back to LISP after having been away for a long, long time (it's
> _hard_ to break the SETQ habit :). BTW, this is not homework of any
> sort.
>
> Anyway, I have a function in my current program which is a planner of
> sorts. It takes a list of stuff as a parameter and builds lists of
> candidates for action.
>
> Pseudo-code:
> (defun chain-stuff (stuff-list start end level)
> (if (<= start end)
> (dolist (stuff stuff-list)
> (when (eligible-p stuff start)
> (chain-stuff stuff-list (+ start 5) end
> (append level stuff))
> )
> ) level
> )
> )

Can you add a little more about what you want to achieve? I /think/ the
pseudocode is off enough to obscure that. Supplying a sample input and
desired output would help a lot.

Suppose eligible-p is '>, and we call chain-stuff thus:

   (chain-stuff '(5 10 3 9 16 25 3) 5 10 nil)

Do you want back?:

   '((10 9 16 25)
     (23 16 25))

btw, the deepest level of call chain-stuff returns the accumulated list
passed to it as the level parameter, but higher levels discard the
return value of recursive calls.

also, you have (append level stuff). Unless stuff is a list you want
joined with the level list as if by concatenation, you want:

    (append level (list stuff))

But it is probably better at this point to get straight what are you
attempting.

kt

-- 
http://tilton-technology.com
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application


Relevant Pages

  • Panic, a strange behavior of lisp program
    ... when SORT is called with a parameter that includes some that ... No actually although CLtL ... this apparent mistake in conversion from CLtL to ANSI-CL. ... Web page that lists all such "obvious" mistakes. ...
    (comp.lang.lisp)
  • RE: Incident investigation methodologies
    ... However, what sort of reaction ... Speculation gets you nowhere. ... > malware we encounter. ... > of what makes public lists useful - you can get some ...
    (Incidents)
  • Re: Detailed explanation of how a QuickSort Works
    ... Firstly, if you consider the simple "Bubble Sort" algorithm, it works by running through the entire data set, one item at a time, comparing each item to the previous item and swapping them if they are not already in the correct order. ... by simply running through the entire list just once (and splitting it into two smaller lists) you have cut the sorting time in half. ...
    (microsoft.public.vb.general.discussion)
  • Re: Ordering Products
    ... algorithms. ... lists with constrained item transpositions. ... I think while the built in sort works as a convenience, ... Overall it's about 10 times slower than pythons built in sort for large ...
    (comp.lang.python)
  • Re: Ordering Products
    ... > Kay Schluehr wrote: ... >> It would be interesting to examine some sorting algorithms on factor ... >> lists with constrained item transpositions. ... > I think while the built in sort works as a convenience, ...
    (comp.lang.python)