Re: Slides and notes from my Picolisp presentation

2018-09-26 Thread Lindsay Lawrence
Thanks for sharing the presentation. Nice insights and a reminder of the 'full-stack' functionality available in picolisp. I've mostly utilized it on the 'server-side'. I would be very interested to hear more detail around how you built out the gui. /Lindsay On Wed, Sep 26, 2018 at 1:27 AM Matt

Re: reading a shell command's output

2018-10-24 Thread Lindsay Lawrence
Perhaps something like... (in '(fzf "-f" "lib") (until (eof) (println (line T /Lindsay On Wed, Oct 24, 2018 at 11:07 AM Curtis wrote: > Thanks for the quick reply. I'll see if I can get 'fzf' to dump it's output > to a temp file. Thank you. > > On Wed, Oct 24, 2018 at 12:46 PM Alexander B

Re: Behavior of sort

2019-05-04 Thread Lindsay Lawrence
Hi, The sort is destructive of the input. https://software-lab.de/doc/refS.html#sort There are other functions that behave like this that you need to be aware of when writing code. You have to assign the result of the sort to another variable. Back to itself is fine. : (setq L '((3) (2) (1))) ->

Re: Fridays for Functions (Was: PilCon 2020)

2020-06-03 Thread Lindsay Lawrence
This is a great idea. Count me in. On Tue, Jun 2, 2020 at 10:59 PM Alexander Burger wrote: > Hi all, > > after we canceled PilCon 2020, we discussed in this list and in IRC the > idea of > doing something online instead. Some people proposed Jitsi. > > A linear format of just streaming presentat

Re: StenoBoard - A Virtual Keyboard for Android

2024-10-23 Thread Lindsay Lawrence
This looks super interesting and useful. While the gist is clear in the videos, an english subtitled version would be great. Best Regards, Lindsay On Tue, Oct 22, 2024 at 6:50 AM Alexander Burger wrote: > Hi all, > > StenoBoard is now my preferred input method, as I have problems with my > fin

How to set internal page links in a PicoLisp Wiki?

2025-01-07 Thread Lindsay Lawrence
Hello, I have been setting up a (for now) internal wiki using the PicoLisp Wiki. Is there a straightforward way with the wiki markup syntax to add an id to a page element, or insert some other kind of id element so I can link into a page. This would be particularly useful for longer pages. For e

Re: How to set internal page links in a PicoLisp Wiki?

2025-01-07 Thread Lindsay Lawrence
ikipage#part' links ( (or (glue " " (cdr S)) (pack (car S))) (pack (car S)) ) (prin "???") (msg '> "render href? :" S) ) ) ) (";" (renderBlock prin)) # lindsay allow raw html

Re: picolisp db encryption?

2025-01-31 Thread Lindsay Lawrence
On Tue, Jan 28, 2025 at 11:40 AM Alexander Burger wrote: > Also, I'm not sure if this is really useful, as it could always be > locally intercepted. > Yes. Any prog doing this would have to implement something to get keys securely for use. > Needs more thinking ... > I agree. Thanks Alex!

Re: Tail call optimization

2025-02-08 Thread Lindsay Lawrence
On Sat, Feb 8, 2025 at 10:16 AM Alexander Burger wrote: > > PicoLisp now has a kind of tail call optimization! > > 👍 👍 Yes! I am looking forward to trying this /Lindsay

Re: Tail call optimization

2025-02-08 Thread Lindsay Lawrence
On Sat, Feb 8, 2025 at 10:16 AM Alexander Burger wrote: > > PicoLisp now has a kind of tail call optimization! > > https://software-lab.de/doc/refT.html#tco > > Hi Alex, I just downloaded the rolling release, but it seems to be missing picolisp "bin/picolisp: not found" Other bits like httpG

Re: Tail call optimization

2025-02-09 Thread Lindsay Lawrence
On Sun, Feb 9, 2025 at 11:18 PM Alexander Burger wrote: > Exactly. 'tco' does not make much difference in total running time. It > is all about stack usage. > > Thanks Alex! > Try with a limited stack size: > > : (stack 8 8) # Stack sizes 8 KiB > -> 8 > : (co 'a (yield)) # Start a coroutine t

Re: Tail call optimization

2025-02-09 Thread Lindsay Lawrence
In trying to compare tco vs recur for my own use I came up with the following: The two functions 'bstInsertTco', 'bstInsertRecur' (see code at end) are identical except for tco,tc and recur,recurse. The repl examples show the degenerate case of inserting an ordered list into a BST without rebalan

Re: Tail call optimization

2025-02-09 Thread Lindsay Lawrence
On Sun, Feb 9, 2025 at 2:36 AM Alexander Burger wrote: > > You can also have use cases for both at the same time. > > For example, a tree can be iterated by recursing on the left branches > and then looping on the right branches: > > Noted. A good thing to remember. It is interesting that I don'

Re: Tail call optimization

2025-02-09 Thread Lindsay Lawrence
> > > It is interesting that I don't see much performance difference between tco > and recur in most cases. > Perhaps the primary difference is their resource usage? > > For example, using (mike)'s fibo example and simply replacing tco with > recur (see code at end) > I initially expected (fibo

Re: Tail call optimization

2025-02-10 Thread Lindsay Lawrence
On Mon, Feb 10, 2025 at 2:49 AM Alexander Burger wrote: > I'd like to point out, however, that recursion and tail call > optimization are not fully equivalent. We always need to keep that in > mind! > > ... > So what PicoLisp does is first clean up everything, by first *leaving* > all enclosing

Re: Tail call optimization

2025-02-10 Thread Lindsay Lawrence
On Mon, Feb 10, 2025 at 6:32 AM Alexander Burger wrote: > On Mon, Feb 10, 2025 at 02:06:52PM +0100, Alexander Burger wrote: > > : (let N 99 (bench (tco (N) (or (=0 N) (tc (dec N)) > > 0.038 sec > > -> 0 > > For the records - and to show the absurdity of TCO - this is of course > the same

Re: Tail call optimization

2025-02-10 Thread Lindsay Lawrence
On Mon, Feb 10, 2025 at 2:49 AM Alexander Burger wrote: > > I'd like to point out, however, that recursion and tail call > optimization are not fully equivalent. We always need to keep that in > mind! > > The original idea of TCO (not the 'tco' function in PicoLisp) is to > avoid that calling the

Re: How do I distinguish a list from cons pair?

2025-02-12 Thread Lindsay Lawrence
On Tue, Feb 11, 2025 at 11:38 PM Alexander Burger wrote: > I would say it is a cell with a non-NIL and non-atomic CDR, then (1 . 2) > is not a list but > >(1 . NIL) # (1) > > or > >(1 . (2 . NIL)) # (1 2) > > is. > > 👍 BTW, 'fin' can be used to distinguish them: > >: (fin (1 2)) >

Re: Yet Another JSON Parser

2025-02-02 Thread Lindsay Lawrence
Hi Alex, You surely know that the references show it by marking evaluated > arguments with a quote, e.g. > >: (help 'case) > >(case 'any (any1 . prg1) (any2 . prg2) ..) -> any >... > > as opposed to > >: (help 'cond) >

Re: Yet Another JSON Parser

2025-02-01 Thread Lindsay Lawrence
Thanks Alex! I appreciate the insight! On Sat, Feb 1, 2025 at 1:45 AM Alexander Burger wrote: >('(" " "^I" "^J" "^M") .. > > Strictly speaking this is not correct or at least not needed, as 'case' > does not evaluate the CARs. > Thanks! I'll fix. I still confuse instances of when CARs and

Re: Yet Another JSON Parser

2025-02-01 Thread Lindsay Lawrence
Hi Geri, > Good thing you're having fun writing useful projects! > I am indeed. Especially now, I am getting past more academic exercises and appreciating how easy it is to wire things together with picolisp. https://en.wikipedia.org/wiki/Unix_philosophy I do want to get a better handle on nativ

Re: Yet Another JSON Parser

2025-01-31 Thread Lindsay Lawrence
On Fri, Jan 31, 2025 at 12:20 PM wrote: > Great. You can never have too many tests. Test your code now too. > > Take the tests from repo and have fun. > > https://git.envs.net/mpech/pil-json > > > (mike) > Wow. That is a great collection of tests, with good insight into how to write my own as wel

Yet Another JSON Parser

2025-01-31 Thread Lindsay Lawrence
Hi, I added another page to the Examples section of the wiki. https://picolisp.com/wiki/?Documentation#yajson Aside from the code, I included several examples of use, along with 'bench' times and a somewhat detailed description. All examples can be run from the repl and more can be found on the

Re: How to set internal page links in a PicoLisp Wiki?

2025-01-08 Thread Lindsay Lawrence
> > > great that you found a solution! > > Thanks Alex! > > This is because the URL after logging in needs more information (mainly > the port and the session ID). > Such cases are e.g. in "wiki/gui.l" > >(if *Login > (baseHRef NIL *SesId "?home") > (baseHRef *Port1 "?home") ) > >

Re: How to set internal page links in a PicoLisp Wiki?

2025-01-08 Thread Lindsay Lawrence
> > > This would be possible, but requires a different session strategy. > > The Pil system forks a child process for each session, which then uses > its own private port to listen for further client connections. > > ... > I believe that the current solution is very good (for several reasons we >

Re: How to set internal page links in a PicoLisp Wiki?

2025-01-10 Thread Lindsay Lawrence
On Fri, Jan 10, 2025 at 12:53 PM Alexander Burger wrote: > Great! So I installed it on picolisp.com, and also released a new TGZ > > Thanks Alex! I am happy to have made a small contribution. /Lindsay

Re: How to set internal page links in a PicoLisp Wiki?

2025-01-09 Thread Lindsay Lawrence
On Thu, Jan 9, 2025 at 1:26 PM Lindsay Lawrence < lawrence.lindsayj...@gmail.com> wrote: > > PS: After all of that, I realize another, and perhaps contextually better, > solution may be to modify the 'wikiLink function, ={ .. } syntax, to handle > '#' when parsin

Re: How to set internal page links in a PicoLisp Wiki?

2025-01-09 Thread Lindsay Lawrence
On Thu, Jan 9, 2025 at 5:18 AM Alexander Burger wrote: > > Cool! If this works, could we also introduce it into the original > version? > > Of course. The ;{ .. } change is straightforward and is useful for more than simple linking. But: Doesn't this conflict with with other URLs having an argu

How to use enum? to check for existence in sparse array

2025-01-28 Thread Lindsay Lawrence
Hi Alex, Is this a bug or is my understanding of how to use enum? from the documentation not correct. I have a little project where I would like to use 'enum. I was using 'idx before, but 'enum looks like a much better fit. My current problem is that in a sparse array I am getting false positiv

Re: How to use enum? to check for existence in sparse array

2025-01-28 Thread Lindsay Lawrence
> Is this a bug or is my understanding of how to use enum? from the > documentation not correct. > > My mistake! The correct syntax is (enum? *HT Val) and not (enum? '*HT Val). I was quoting the tree name. Doh! Regards, Lindsay Note: I am still not entirely clear why 'enum? can return unexpect

Re: How to use enum? to check for existence in sparse array

2025-01-28 Thread Lindsay Lawrence
> > Note: I am still not entirely clear why 'enum? can return unexpected (at > least to me) results in the sparse array case (see below) > Is it because 'enum precreates key nodes in the tree for a sparse array in > order to keep it balanced?. > > Ok. I think I get the structure. (val (enum? *HT Va

Connecting stderr

2025-01-28 Thread Lindsay Lawrence
Hi, When calling, or piping, to an external process from picolisp, is there a way to connect the stderr of that process on another channel as well, so that it can be read, and distinguished, from stdout. /Lindsay

Re: How to set initial job environment values?

2025-01-28 Thread Lindsay Lawrence
> > > > 'curry' is a bit overkill here. I would directly 'fill' a 'job': > Thanks! 'fill' is indeed the function I was looking for here. Working with 'nth', I did learn more about the picolisp machine and list internals. /Lindsay z

Re: Delayed Mails

2025-01-28 Thread Lindsay Lawrence
On Tue, Jan 28, 2025 at 9:47 AM Alexander Burger wrote: > Sorry for the five delayed Mails! It was my fault :( > > ☺/ A!ex 👍

picolisp db encryption?

2025-01-28 Thread Lindsay Lawrence
Question: Is it possible to encrypt picolisp dbs on the fly? For example, to hook into the low level functions that do block reads and writes in order to apply encryption? For example, it would be a useful option, when setting up a 'pool' to specify a key that is used to decrypt/encrypt block rea

Re: Connecting stderr

2025-01-28 Thread Lindsay Lawrence
On Sat, Jan 25, 2025 at 8:56 AM Lindsay Lawrence < lawrence.lindsayj...@gmail.com> wrote: > Is there a straightforward way from PicoLisp, when executing an external > process, to get stderr on a separate channel? > I'd like to do something like (pipe) where I can connect std

Updated wiki example

2025-01-28 Thread Lindsay Lawrence
Hi, https://picolisp.com/wiki/?RunExe I optimized the code used in the example I previously added to the wiki. Being able to pipe 1M inserts into a sqlite db in ~2.5secs from picolisp is all kinds of awesome. I also added a link to an additional example: https://github.com/thinknlive/picolisp-li

Re: Connecting stderr

2025-01-28 Thread Lindsay Lawrence
On Wed, Jan 15, 2025 at 10:02 AM Lindsay Lawrence < lawrence.lindsayj...@gmail.com> wrote: > Hi, > > When calling, or piping, to an external process from picolisp, is there a > way to connect the stderr of that process on another channel as well, so > that it can be read,

How to set initial job environment values?

2025-01-28 Thread Lindsay Lawrence
Hi, Is there a simpler way to set the curry environment's State value to Seed than what I am doing here? Regards, Lindsay (de randomLehmer (Seed) (let (Fn (curry ((State . 1)) NIL (setq State (% (* State 279470273) 4294967291)) ) ) (set

Question on (run 'any ['cnt]) -> any behavior

2025-01-04 Thread Lindsay Lawrence
Hi, I've been tinkering with some picolisp code and in investigating the use of "run" I am seeing an inconsistency between the docs and my environment. The 'cnt parameter does not seem to reference the nth call environment (see full code at end). In the example in the docs the result is .. (Prg

Re: Question on (run 'any ['cnt]) -> any behavior

2025-01-04 Thread Lindsay Lawrence
Thanks Alex! /Lindsay On Sat, Jan 4, 2025 at 10:54 AM Alexander Burger wrote: > Hi Lindsay, > > > I've been tinkering with some picolisp code and in > > investigating the use of "run" I am seeing an inconsistency > > between the docs and my environment. > > > > The 'cnt parameter does not s

Question: How to get input value and not echo it to display in vip?

2025-01-04 Thread Lindsay Lawrence
I have been digging into the vip code recently. Initially to get a better understanding on namespacing and scope in pil21. However, I am really appreciating how powerfully extensible vip is. I added a couple of cmds (not yet moved to viprc) to encrypt and decrypt entire buffers (see below where

Re: Question: How to get input value and not echo it to display in vip?

2025-01-05 Thread Lindsay Lawrence
Thanks Alex! That was a nice cue. In my viprc I've ended up with the code below. I can now define one or more named keys and use them to encrypt/decrypt buffers in a given session without showing the key Regards, Lindsay (setq *EncKeys '(("yek" . "key"))) (cmd "yek" (L Lst Cnt) # Set named enc

Re: How to set internal page links in a PicoLisp Wiki?

2025-01-10 Thread Lindsay Lawrence
On Fri, Jan 10, 2025 at 3:01 AM Alexander Burger wrote: > I would slightly change it to suppress the "#" if no > jump label is given: > >(de wikiLink (Lst) > (let > (L (++ Lst) > S (split L "#") > Nm (or (pack (car S)) (: nm)) > Loc (if (cdr

Re: How to set internal page links in a PicoLisp Wiki?

2025-01-09 Thread Lindsay Lawrence
> This is easy. Set in your initial code > >(setq *HPorts (8040 . 8079)) > > for such a range. > > Thanks!... I was almost there :) One other minor point, with resulting question, I worked through; In http.l 'server why is '*Port1 initialized this way? *Port1 (or (sys "NAME") Port) As it ha

Re: How to set internal page links in a PicoLisp Wiki?

2025-01-09 Thread Lindsay Lawrence
On Thu, Jan 9, 2025 at 1:25 AM Alexander Burger wrote: > > This is for the interaction with httpGate > >@doc/httpGate.html > > Thank you. My working version for linking into a wiki page (handling sessions) and support for raw html looks like the code below which lets me write wiki code like

Re: Tail call optimization

2025-02-14 Thread Lindsay Lawrence
> > How about a coroutine version? > > Neat! You have options over what to do with the digits with the coroutine. And negligible difference in performance, if it matters, either. I didn't expect that. /Lindsay : (bench (out "pi-digits.1.txt" (makePi 1))) 3.150 sec -> NIL : (bench (out "pi-dig

Re: Tail call optimization

2025-02-08 Thread Lindsay Lawrence
On Sat, Feb 8, 2025 at 11:41 AM Lindsay Lawrence < lawrence.lindsayj...@gmail.com> wrote: > I just downloaded the rolling release, but it seems to be missing > picolisp "bin/picolisp: not found" > Other bits like httpGate etc are missing from bin/ as well. > >

Re: Tail call optimization

2025-02-08 Thread Lindsay Lawrence
On Sat, Feb 8, 2025 at 10:16 AM Alexander Burger wrote: > PicoLisp now has a kind of tail call optimization! > I gave 'tco' a try. I appreciate the syntax. The similarity with existing recur syntax makes it trivial to convert code where tail calls are possible. In my bench tests below with a b

How do I distinguish a list from cons pair?

2025-02-11 Thread Lindsay Lawrence
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

Re: Tail call optimization

2025-02-11 Thread Lindsay Lawrence
> 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

Re: Tail call optimization

2025-02-12 Thread Lindsay Lawrence
On Tue, Feb 11, 2025 at 11:25 PM Alexander Burger wrote: > > If a problem is a linear operation, like traversing a list, a loop is > more natural for me. For traversing a tree, recursion is better of > course. > > Thanks! >(de fiboSwap (N) > (let (A 0 B 1) > (do N >

On fixed point annotation in the repl

2025-03-22 Thread Lindsay Lawrence
Not sure when it was added, but I just want to say that the added annotation for fixed point values, when scl is set, is an amazingly useful feature for the repl. : (scl 3) -> 3 # 0.003 (*/ 1.0 1050546 15970) -> 65782 # 65.782 Makes it so much easier to work with scaled numbers and debug issues

Re: Tail call optimization

2025-02-13 Thread Lindsay Lawrence
On Thu, Feb 13, 2025 at 9:37 AM Alexander Burger wrote: > On Thu, Feb 13, 2025 at 08:50:16AM -0800, Lindsay Lawrence wrote: > > I think it is also a good a test/example of picolisp's support for > bignums. > > Indeed. The numbers in the 'E' environment get quite

Re: Tail call optimization

2025-02-13 Thread Lindsay Lawrence
> > > > Sorry again for the confusion! > > 👍 I think it is also a good a test/example of picolisp's support for bignums. It could be a fun exercise to implement a version of this with one of the other Pi algorithms that discards already computed digits so it could essentially just churn out digit

Re: Tail call optimization

2025-02-13 Thread Lindsay Lawrence
On Thu, Feb 13, 2025 at 9:37 AM Alexander Burger wrote: > On Thu, Feb 13, 2025 at 08:50:16AM -0800, Lindsay Lawrence wrote: > > I think it is also a good a test/example of picolisp's support for > bignums. > > Indeed. The numbers in the 'E' environment get quite

Re: Tail call optimization

2025-02-12 Thread Lindsay Lawrence
> Hmm, it seems that I begin to detect some advantages in tco/tc :) > > For example, in pil64 I had a function calculating the digits of pi ad > infinitum: > ># Print next digit of PI >(de piDigit () > (job '((Q . 1) (R . 0) (S . 1) (K . 1) (N . 3) (L . 3)) > (while (>= (- (+

Re: Tail call optimization

2025-02-14 Thread Lindsay Lawrence
On Thu, Feb 13, 2025 at 9:49 PM Lindsay Lawrence < lawrence.lindsayj...@gmail.com> wrote: > A bit of searching came up with the paper with the haskell version > > https://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/spigot.pdf > > Interestingly enough there is ano

Re: Tail call optimization

2025-02-14 Thread Lindsay Lawrence
On Fri, Feb 14, 2025 at 8:58 AM Alexander Burger wrote: > The old algorithm needed for 10 digits 8369 sec (02:19 h), the new > one (I use the coroutine version) just 726 sec. That's about 12 times as > fast! > 👍 👍 :) /Lindsay