Re: Enumerated Trees in PicoLisp

2021-04-01 Thread Terry Palfrey
I was already primed by Scott Adams biology experiment. Being an accelerationist and convergentist. On Thu, 25 Mar 2021 at 02:45, Alexander Burger wrote: > Hi all, > > PicoLisp has a really cool new function! > > It is called 'enum', because it "enumerates" arbitrary Lisp values. That > is,

Re: Enumerated Trees in PicoLisp

2021-04-01 Thread Alexander Burger
Hi all, On Thu, Mar 25, 2021 at 10:40:21AM +0100, Alexander Burger wrote: > 'enum' is similar to 'idx' with numeric keys. But with 'idx', the keys take up > one additional cell per entry, and the insertion order is relevant. > > > (enum 'var 'cnt 'any) -> any # stores a value > (enum 'var

Re: Enumerated Trees in PicoLisp

2021-03-25 Thread Mike
March 25, 2021 9:48 AM, "Alexander Burger" wrote: > PicoLisp has a really cool new function! Test added and tested in LLVM 7, 11-13. (mike) -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Re: Enumerated Trees in PicoLisp

2021-03-25 Thread Alexander Burger
On Thu, Mar 25, 2021 at 10:40:21AM +0100, Alexander Burger wrote: > 3. The tree is automatically balanced, independent of the insertion order. This is only true if there are no final gaps in the keys. What we can say, however, is that every item is placed at a depth which is the 2-logarithm of

Re: Enumerated Trees in PicoLisp

2021-03-25 Thread Alexander Burger
On Thu, Mar 25, 2021 at 01:06:58PM +0100, Tomas Hlavaty wrote: > > And useless for the intended purpose. At least I see no way to insert and > > look > > up by number (?) > > because you always take the position in the binary heap as the key. OK, so this won't work : (enum 'E 999 "Test")

Re: Enumerated Trees in PicoLisp

2021-03-25 Thread Tomas Hlavaty
On Thu 25 Mar 2021 at 12:23, Alexander Burger wrote: > On Thu, Mar 25, 2021 at 12:11:55PM +0100, Alexander Burger wrote: >> Binary heaps are close, but not the same. > > And useless for the intended purpose. At least I see no way to insert and look > up by number (?) because you always take the

Re: Enumerated Trees in PicoLisp

2021-03-25 Thread Alexander Burger
On Thu, Mar 25, 2021 at 12:11:55PM +0100, Alexander Burger wrote: > Binary heaps are close, but not the same. And useless for the intended purpose. At least I see no way to insert and look up by number (?) ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Re: Enumerated Trees in PicoLisp

2021-03-25 Thread Alexander Burger
Hi Tomas, > binary heap Thanks! Binary heaps are close, but not the same. Pil's algorithm is a lot more efficient. Just bit test and shift, as opposed to the swapping of nodes as described in https://en.wikipedia.org/wiki/Binary_heap ☺/ A!ex -- UNSUBSCRIBE:

Re: Enumerated Trees in PicoLisp

2021-03-25 Thread Tomas Hlavaty
On Thu 25 Mar 2021 at 10:40, Alexander Burger wrote: > Probably this algorithm exists already, because it is so simple and obvious. > But > I found it by myself and did not bother to search for it (mainly because I > don't > know what name to search for). binary heap -- UNSUBSCRIBE:

Re: Enumerated Trees in PicoLisp

2021-03-25 Thread Alexander Burger
Hi Mike, > Test added and tested in LLVM 7, 11-13. Ah, yes, I forgot to add to unit tests. Will add there too. ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Enumerated Trees in PicoLisp

2021-03-25 Thread Alexander Burger
Hi all, PicoLisp has a really cool new function! It is called 'enum', because it "enumerates" arbitrary Lisp values. That is, it associates values with numbers, by storing them in a binary tree structure. The cool points are: 1. The numeric keys themselves are not stored. They are implicit.