On Mon, Feb 10, 2025 at 10:18:41PM -0800, Lindsay Lawrence wrote:
> I realized several existing recursive functions I use were trivially
> convertible and are now able to work with much larger lists.
>
> I put a few examples here: swap, mtf (move to front), mft (move from top)
>
> https://githu
Is there a way to distinguish a list from a cons pair?
The 'pair' function does not seem to do what I want.
: (pair (cons 1 2))
-> (1 . 2)
: (pair (list 1 2))
-> (1 2)
: (pair (list 1 (2 3)))
-> (1 (2 3))
: (pair (cons 1 (2 3)))
-> (1 2 3)
I would like to be able to distinguish the cons pair str
Hey,
I'm curious myself honestly.
Lists are kind of a virtual type, it's just a bunch of cons cells in a
sequencial pattern.
I think you'd need to write your own function that walks the list to see if
its proper or improper (ends with non-nil).
Best regards,
Geri
On Wed, Feb 12, 2025, 08:28 Li
> I usually approach such tasks with loops, with a rather
> different mental model.
>
>
That is interesting! Can you say more about your mental model?
I am often surprised by how often I end up with recursive solutions when
hacking on a particular problem in picolisp.
Concerning swap, we could for
On Tue, Feb 11, 2025 at 02:41:01PM -0800, Lindsay Lawrence wrote:
> > I usually approach such tasks with loops, with a rather
> > different mental model.
> >
> That is interesting! Can you say more about your mental model?
> I am often surprised by how often I end up with recursive solutions when
>
On Tue, Feb 11, 2025 at 10:16:14PM -0800, Lindsay Lawrence wrote:
> Is there a way to distinguish a list from a cons pair?
>
> The 'pair' function does not seem to do what I want.
It depends on how you define a list.
I would say it is a cell with a non-NIL and non-atomic CDR, then (1 . 2)
is not
On Wed, Feb 12, 2025 at 08:31:03AM +0200, GB wrote:
> Lists are kind of a virtual type, it's just a bunch of cons cells in a
> sequencial pattern.
Exactly.
> I think you'd need to write your own function that walks the list to see if
> its proper or improper (ends with non-nil).
Right. 'fin' do