<freemint>
Regenaxer is there a function which does (A 3 2 A) to ((A A) 3 2) {ordering does not matter} or (A 3 2 A) to ((A . 2) (3 . 1) (2 . 1)) ?
<Regenaxer>
Seems similar to 'group'?
<Regenaxer>
I think 'accu' comes close
<Regenaxer>
(for X Lst (accu 'Var 1))
<Regenaxer>
: (for X '(A 3 2 A) (accu 'Res X 1))
<Regenaxer>
-> 2
<Regenaxer>
: Res
<Regenaxer>
-> ((2 . 1) (3 . 1) (A . 2))
<freemint>
did just that
<freemint>
is there a non destructive sort or is copying beforehand prefered?
<Regenaxer>
This list is new, so destru
<Regenaxer>
ctive is preferred
<freemint>
Regenaxer is there an "identity function" in PicoLisp?
libertas has quit [Ping timeout: 250 seconds]
<freemint>
(by 'identity group List)
<Regenaxer>
'=' or '=='?
<Regenaxer>
Define identity
libertas has joined #picolisp
<freemint>
a function which returns what it was passed with no modification sort of like ((X) X) but maybe more general?
<Regenaxer>
No-op is 'prog'
<freemint>
that works
<freemint>
(by 'prog group List), does that looke good?
<Regenaxer>
No quote needed
<freemint>
(look as in your opinion?)
<freemint>
ok
<Regenaxer>
yes, fine
<freemint>
oh right
<freemint>
i did not 'group this time
<Regenaxer>
good :)
<freemint>
Is there a function which behaves like (X X) implemented?
<Regenaxer>
you mean non-evaluating? This is quote
<freemint>
right
libertas has quit [Ping timeout: 246 seconds]
xkapastel has quit [Quit: Connection closed for inactivity]
freemint has quit [Ping timeout: 268 seconds]
<razzy>
how does (in NIL (let (Num (read)) (Num1 (read)) )) know when i finished input and i want to close reading standard input.
<razzy>
sometimes i want to read 1 num, sometimes i want to read 2 numbers
<razzy>
i could use something like (in NIL (while (let ((pack 'Num (inc (0)) (read)) )))) but it would not know when to end right?
<razzy>
i mean (read) uses both enter and space as (read)-separator
<Regenaxer>
(in ...) always reads until EOF, unless you exit the body yourself
<Regenaxer>
(in NIL (let (Num (read)) (Num1 (read)) is wrong btw
<Regenaxer>
and yes, any white spaces (and comments) are skipped by 'read'
<razzy>
it works if i want to read "gogo a4 f4" i (read) 3 times and i have gogo a4 f4 in respective Nums
xkapastel has joined #picolisp
<Regenaxer>
yes, this is good
<Regenaxer>
However, for reading plain data (not s-exprs) 'read' is probably not optimal
<Regenaxer>
I would do (split (line) " ")
<Regenaxer>
or (mapcar pack (split (line) " "))
<Regenaxer>
or whatever is useful to parse the data
rob_w has quit [Quit: Leaving]
<Regenaxer>
*if* you want to use 'read', you could check for end of line
<Regenaxer>
(in "xxx" (make (until (prog (link (read)) (eol)))))
<razzy>
https://ptpb.pw/YIpQ this is how (read) consider space and end-of-line as same separator. i still do not know, how this code "know" that i finished input
<razzy>
checking for eol should work
<razzy>
thx
<razzy>
the goal is to have more interactive software, without need for adding () everywhere for simplest commands
freemint has joined #picolisp
<freemint>
i read a comment section about SQL (on news.ycombinator.com) today. I am impressed with SQL. A SQL DMS at pilDB are not comparable at all.
freemint has quit [Remote host closed the connection]
xkapastel has quit [Quit: Connection closed for inactivity]
xkapastel has joined #picolisp
<razzy>
is there (member) func that return everything up to point? something like (reverse (member X (reverse Lst))) ?
<Regenaxer>
You can use head, but it takes a count
<Regenaxer>
so (head (index X Lst) Lst) or so
<razzy>
hmm hmm thx
<Regenaxer>
(reverse (member X (reverse Lst))) is better (flip (member X (reverse Lst)))
<Regenaxer>
but works only if X is unique in Lst
<Regenaxer>
if so, I think this is fine
<razzy>
can i use (by) with (member) somehow? if i want to list all members that have same (cadr) -- i hope it is understandable
<Regenaxer>
yes, understandable, but 'by' does not help here
<Regenaxer>
'by' with 'group' work
<Regenaxer>
(by cadr group Lst)
<Regenaxer>
or (filter '((X) (= Y (cadr X))) Lst) ?
<razzy>
and with filter i hope
<Regenaxer>
:)
<razzy>
ah, member is so useless
<Regenaxer>
Not at all :)
<Regenaxer>
It is a special case of 'find' and 'seek' etc
<razzy>
more readable for programmer?
<Regenaxer>
yes, and a lot faster
<Regenaxer>
especially 'memq'
xkapastel has quit [Quit: Connection closed for inactivity]