Re: Newbie Design Question
From: Kenny Tilton (ktilton_at_nyc.rr.com)
Date: 11/23/03
- Next message: Pascal Bourguignon: "Re: Why do lisps have stack limits?"
- Previous message: Mario S. Mommer: "Re: Why do lisps have stack limits?"
- In reply to: Jeff Katcher: "Newbie Design Question"
- Next in thread: Jeff Katcher: "Re: Newbie Design Question"
- Reply: Jeff Katcher: "Re: Newbie Design Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Pascal Bourguignon: "Re: Why do lisps have stack limits?"
- Previous message: Mario S. Mommer: "Re: Why do lisps have stack limits?"
- In reply to: Jeff Katcher: "Newbie Design Question"
- Next in thread: Jeff Katcher: "Re: Newbie Design Question"
- Reply: Jeff Katcher: "Re: Newbie Design Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|