Check for repeating circular lists

2011-03-04 Thread Jon Kleiser
Hi Alex, I noticed here <http://code.google.com/p/picolisp/updates/list> that you did an update re. "Check for repeating circular lists" the other day. Is a "repeating circular lists" a special case of a circular lists? If so, could you give an example of such

Re: Check for repeating circular lists

2011-03-04 Thread Alexander Burger
Hi Jon, > you did an update re. "Check for repeating circular lists" the other > day. Is a "repeating circular lists" a special case of a circular > lists? If so, could you give an example of such a repeating circular > lists? Yes, it is a special case, for e

Re: Pico, difficulty with circular lists

2008-04-10 Thread Alexander Burger
Hi Jon, > (length '(de *Day . (Mon Tue Wed Thu Fri Sat Sun .))) > .. > Why does 'length' have such problems here? Circular lists are generally rather dangerous. PicLisp supports (kind of ;-) only what I would call "primary circular lists", i.e. lists that circu

Pico, difficulty with circular lists

2008-04-10 Thread Jon Kleiser
Hi Alex, After you made me aware of the circular list in lib/form.l, I changed my 'ifwarn' function to skip circular lists by putting in the (nT (length Prg)) test, like this: (de ifwarn (Prg) (when (and (lst? Prg) (nT (length Prg))) (when (and (= (ca

Re: Pico, difficulty with circular lists

2008-04-11 Thread Jon Kleiser
Hi again, > (length '(de *Day . (Mon Tue Wed Thu Fri Sat Sun .))) .. Why does 'length' have such problems here? Circular lists are generally rather dangerous. PicLisp supports (kind of ;-) only what I would call "primary circular lists", i.e. lists that circ

Re: Cutting a circular list.

2008-10-10 Thread Henrik Sarvell
There has been some prior discussion on the list: http://www.mail-archive.com/search?q=circular+lists&l=picolisp%40software-lab.de It might or might not be of help. /Henrik -- UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

issue with circular lists

2020-12-23 Thread Davide BERTOLOTTO
Hi everyone, I had recently an issue with both pil64 and pil21. I was trying to create a large circular list and got a segmentation fault with a size of >200'000 elements. Is that expected? (apply circ (range 1 20)) Regards, Davide

Re: Pico, difficulty with circular lists

2008-04-10 Thread John Duncan
Only simple circular lists seem to work properly. '(a b . (c d e .)) is equivalent to '(a b c d e c d e ...) : (de X . (a b .)) -> X : X -> (a b .) : (de X . (a . (b c .))) # X redefined -> X : (cdr X) -> (b c .) : X -> (a b c b c b c b c b c b c b c b c b c b c b c

Mapping circular lists from Emacs Lisp to PicoLisp

2013-06-28 Thread Thorsten Jolitz
Hi List, I try to figure out if it would be possible to map circular lists from Emacs Lisp to PicoLisp. Here is a quote from the Emacs Lisp manual : #+begin_quote If the cdr of a list's last cons cell is some value other than nil, we call the structure a dotted list, since its pr

Re: Mapping circular lists from Emacs Lisp to PicoLisp

2013-06-28 Thread Alexander Burger
Hi Thorsten, > In PicoLisp, the cdr of a circular list always seems to point to the beginning > of the list. Yes, as far as the directy reader/printer syntax is concerned. But you can easily specify a list where the last cell points to some other cell. For example, in this list of 6 cel

Re: Mapping circular lists from Emacs Lisp to PicoLisp

2013-06-28 Thread Thorsten Jolitz
Alexander Burger writes: Hi Alex, >> In PicoLisp, the cdr of a circular list always seems to point to the >> beginning of the list. > > Yes, as far as the directy reader/printer syntax is concerned. But you > can easily specify a list where the last cell points to some

Re: issue with circular lists

2020-12-23 Thread Davide BERTOLOTTO
an issue with both pil64 and pil21. I was trying to create > a large circular list and got a segmentation fault with a size of >200'000 > elements. Is that expected? > > (apply circ (range 1 20)) > > Regards, > Davide >

Re: issue with circular lists

2020-12-23 Thread Alexander Burger
case, I would recommend 'fifo' to build large circular structures: (let L NIL (for I 20 (fifo 'L I) ) ... The result is a little different though: : (let L NIL (for I 7 (fifo 'L I)) L) -> (7 1 2 3 4 5 6 .) Depends on the use case. ☺/ A!ex

Re: Wacky stuff with circular lists, Was:The many uses of @

2011-11-10 Thread Alexander Burger
On Thu, Nov 10, 2011 at 07:14:06PM +0700, Henrik Sarvell wrote: > Why don't you guys make a wiki page out of this one too? Well, José mumbled in IRC something in that direction ... ;-) -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Re: issue with circular lists

2020-12-23 Thread Alexander Burger
Hi Davide, > Just found out that it is an issue with apply. Probably the number of > arguments is too large. > > (eval (cons 'circ (range 1 20))) Yes, this is a known issue. It is a stack overflow. 'apply' builds structures on the stack. The recommended way is to set ulimit -s unlimite

Re: 'pre?', 'sub?' and 'length'

2008-10-26 Thread Alexander Burger
Hi Tomas, > : (pre '(1 2) '(1 2 3 4)) > -> T > : (pre '(1 2) '(1 5 2 3 4)) > -> NIL This would make sense. That functionality is covered by 'head', though. > 'length' returns T for circular lists currently, which is not great.

Re: issue with circular lists

2020-12-23 Thread Alexander Burger
On Wed, Dec 23, 2020 at 01:57:10PM +0100, Alexander Burger wrote: > The result is a little different though: > >: (let L NIL (for I 7 (fifo 'L I)) L) >-> (7 1 2 3 4 5 6 .) .. but of course the fix is trivial :) : (cdr (let L NIL (for I 7 (fifo 'L I)) L)) -> (1 2 3 4 5 6 7 .) ☺/ A!

Re: Wacky stuff with circular lists, Was:The many uses of @

2011-11-08 Thread Thorsten
José Romero writes: >> > (and 5 . ((prinl @) (gt0 (dec @)) .)) > If it helps, this is how that S-expression should look in memory, I > omitted the technically correct representation of numbers and symbols > to keep it simple: > > ,---, > +---+---+ +---

Re: issue with circular lists

2020-12-23 Thread Davide BERTOLOTTO
Thanks for the clarification Alex! The ulimit command did the trick. Cheers, Davide On Wed, Dec 23, 2020, 14:16 Alexander Burger wrote: > On Wed, Dec 23, 2020 at 01:57:10PM +0100, Alexander Burger wrote: > > The result is a little different though: > > > >: (let L NIL (for I 7 (fifo 'L I))

Re: Pico, difficulty with circular lists

2008-04-11 Thread Alexander Burger
On Fri, Apr 11, 2008 at 04:46:14PM +0200, Alexander Burger wrote: > Exact. The function 'MUL' is defined before that, but as you just read > the file (without executing it), it will be undefined when you hit that > read macro. Well, and while thinking about it: Inspecting files in such a way (with

Re: Wacky stuff with circular lists, Was:The many uses of @

2011-11-10 Thread Henrik Sarvell
Why don't you guys make a wiki page out of this one too? On Wed, Nov 9, 2011 at 6:54 AM, Thorsten wrote: > José Romero > writes: > >>> >   (and 5 . ((prinl @) (gt0 (dec @)) .)) > >> If it helps, this is how that S-expression should look in memory, I >> omitted the technically correct representa

Re: Wacky stuff with circular lists, Was:The many uses of @

2011-11-10 Thread Alexander Burger
Hi Thorsten, > And now I'm listed as the author of this wiki page, but it should > actually be Jose. Maybe he can make a little change to the page, so > that his name appears too? BTW, there is of course an "illegal" way to change it, by going to the maintenance GUI, clicking on "Documents", then

Re: Pico, difficulty with circular lists

2008-04-11 Thread Alexander Burger
Hi Jon, > the 'length' function, I've written a new function 'longer' that > works OK, like this: > > # Returns N+1 if Lst is longer than N, otherwise NIL > (de longer (Lst N) > (for (I . X) Lst > (T (> I N) I) > NIL) ) Yep, this is a good solution. > [rcsim/

Re: Wacky stuff with circular lists, Was:The many uses of @

2011-11-10 Thread Thorsten
Alexander Burger writes: > Hi Thorsten, > >> And now I'm listed as the author of this wiki page, but it should >> actually be Jose. Maybe he can make a little change to the page, so >> that his name appears too? > > BTW, there is of course an "illegal" way to change it, by going to the > maintena

'pre?', 'sub?' and 'length'

2008-10-26 Thread Tomas Hlavaty
etq P (cdr P) L (cdr L)) (off X) ) ) X ) ) : (pre '(1 2) '(1 2 3 4)) -> T : (pre '(1 2) '(1 5 2 3 4)) -> NIL 'length' returns T for circular lists currently, which is not great. It could return the real length too (as the number of 'car&

Wacky stuff with circular lists, Was:The many uses of @

2011-11-08 Thread José Romero
t i was passed, the first argument, > > evaluating it results in a function call that returns 5, it's not > > nil, so i shove it to @ and go on. The next element is another > > list, a call to prinl happens, it returned 5, it's not nil, so i > > shove it to @ and g

Re: Subscribe

2017-03-22 Thread Alexander Burger
lls, no bignums, no garbage collection, no sharing of (sub)lists, no circular structures - in my opinion the things which make up the real power of Lisp. Even multiple variables pointing to the same object are not allowed. An advantage of NewLisp is that it runs also on Windows, while PicoLisp require

Re: Pil21 feature questions

2020-11-10 Thread Alexander Burger
e names in 'pico', but still *new* symbols will be interned in 'pico'. > - What is the purpose of the ‘~’ marker in the namespaces? This is only used for error checking: To check in 'symbols' that the arguments are really namespaces, and that 'nsp' in 

Re: Pil21 feature questions

2020-11-10 Thread Andras Pahi
t be overridden by symbols with the same > names in 'pico', but still *new* symbols will be interned in 'pico'. > > >> - What is the purpose of the ‘~’ marker in the namespaces? > > This is only used for error checking: To check in 'symbols' that the argum

Re: P35 Prime Factors

2017-02-25 Thread Lindsay John Lawrence
Hi Alex, Joh-Tob, Thank you. With the Knuth reference the code makes a lot more sense! I had implemented a more basic version. For large ranges, the performance difference of the Alex's iterative version that utilizes the sequence is much better! It is a very nice use of circular

Re: onOff question

2009-10-10 Thread Alexander Burger
e plus half a cell), accessing the pointer with CAR (offset zero) and CDR (offset half a cell size) is legal and will always return NIL again. This allows a very fast traversal of lists, without the need for checking for end-of-list. So (3) comes without any cost. > Anyway, I just couldn'

Re: onOff question

2009-10-10 Thread TC
iple of the cell size plus half a cell), accessing the pointer with CAR (offset zero) and CDR (offset half a cell size) is legal and will always return NIL again. This allows a very fast traversal of lists, without the need for checking for end-of-list. So (3) comes without any cost. I'll dig

Re: quote form in picolisp

2021-12-16 Thread pd
ned dotted pair) ends in NIL we call it proper list and when not ending in NIL but in any other atom, we call it improper list. So picolisp HAS proper and improper list ;-) in fact a circular list is a kind of improper list and we all known picolisp has circular lists > As we are interpreter-o

Re: picolisp reader dot handling inconsistency

2009-10-04 Thread Tomas Hlavaty
. 1) -- Bad dotted pair ? -> 2 ? Is the error case "Bad dotted pair" necessary? : '(. . .) -> (\. . \.) Why is the last dot treated as a symbol and not as a circular list? : '(. . . .) (\. . \.) -- Bad dotted pair ? Bad input ')' (41) ? : What is (should be) this? !? (.) -- Und

Re: digging dotted pairs

2011-03-13 Thread José Romero
3), because they are the same.=20 The dotted pair is also called "cons cell", it's the building block for more complex lisp data structures, like lists or trees. Each cons cell has two parts, it's CAR and CDR (they used to be acronyms that used to mean something, but now t

Re: Extending the wiki markup syntax

2016-03-09 Thread Thorsten Jolitz
software. Under the hood, an Org-mode document is a nested (Emacs Lisp) list, which is of course very convenient from a PicoLisp point of view. Unfortunately, the Org-mode parser (org-element.el) makes use of some unique Emacs Lisp features (circular lists, text properties ...) that complicated

Re: a bunch of questions about syntax

2017-01-27 Thread Alexander Burger
plain "cells". "list" is a rather unprecise term, I feel it is not > >> limited to "a > >> chain of cells with NIL at the end". I use "list" for any sequence of > >> cells (as > >> opposed to other structures like "tre

Re: a bunch of questions about syntax

2017-01-27 Thread pd
rather unprecise term, I feel it is not limited > to "a > chain of cells with NIL at the end". I use "list" for any sequence of > cells (as > opposed to other structures like "tree", "graph" or "set"). These include > also > e.g. &q

PicoLisp macros

2012-01-25 Thread Axel Svensson
If it is expanded as a macro, you'll never feel safe when quoting a list that's supposed to be data, but if it's not expanded you won't be able to use quoted lists to pass code into other functions, at least not without feeling the agony of the supposed runtime penalty. In a la

Re: a bunch of questions about syntax

2017-01-27 Thread pd
uot; for any sequence of >> cells (as >> opposed to other structures like "tree", "graph" or "set"). These include >> also >> e.g. "circular lists" like (1 2 3 .), which have no NIL at the end (in >> fact, no >> end at a

Re: a bunch of questions about syntax

2017-01-26 Thread Alexander Burger
ology of "list" versus "cons pairs" and plain "cells". "list" is a rather unprecise term, I feel it is not limited to "a chain of cells with NIL at the end". I use "list" for any sequence of cells (as opposed to other structures like "