<Hunar>
Hello :) what is an easy way to turn this (0 1 2) into '((1 0 0) (0 1 0) (0 0 1))
<Hunar>
(rot) would have been great if it also accepted the number of rotations
<abu[m]>
Hi Hunar! You can do (do 3 (rot L)), but I still don''t understand the question
<abu[m]>
How (0 1 2) -> '((1 0 0 ...
<Hunar>
I have a long list of numbers, i want to convert each number into a list, where only the nth element is 1 according to the number
<Hunar>
numbers are from 0 to 9
<Hunar>
(append (need N 0) (1) (need (- 9 N) 0))
<Hunar>
I think this is what I need
<abu[m]>
Less efficient, but perhaps simpler: (de f (N) (mapcar format (chop (bin (** 2 (dec N))))))
<abu[m]>
Instead of '**' better '>>'
<abu[m]>
(** 2 3) is (>> -3 1)
<Hunar>
I tried your code, the list size should always be 10, your's changes, and needs a reverse I think
<abu[m]>
Ah, I thought shorter lists are better
<abu[m]>
Anyway 'bin' is too expensive
<Hunar>
Ok, I'll use the append then :) seems like the simplest. thanks
<abu[m]>
A small speed up is to use 'conc' instead of 'append'
<Hunar>
I'm doing something that will stress PicoLisp arithmetic speed
<abu[m]>
Avoiding garbage
<Hunar>
a list of 60000 items, each item is 28*28 numbers, each iteration needs multiple matrix multiplications
<Hunar>
i.e 60000 by 784 nested list
<abu[m]>
Another small improvement: (de f (N) (prog1 (need 10 0) (set (nth @ (- 11 N)) 1)))
<abu[m]>
Ah, yes, matrices. That's why the zeroes and ones.
<Hunar>
I'm going to torture picolisp :) bbl
<abu[m]>
βΊπ
<beneroth>
so we get soon some benchmark on vector/matrix number crunching in pil? :D
<beneroth>
it should be inherently worse than specialized software because of the random access cell memory we have. but then there might be surprises :D
<abu[m]>
Probably, yes. Also number crunching is not something Pil is good at
<beneroth>
on purpose
<abu[m]>
right
<beneroth>
universal programming language is somewhat an oxymoron
<abu[m]>
the data structures
<beneroth>
yeah
<beneroth>
but the data structures in pil are best for quick development and changes of business/user application which can change often because of unclear requirements or changes in processes
<abu[m]>
very true
<beneroth>
math is not changing that much, so it right to apply specialization and optimization for the specific case there
<beneroth>
right tool for the right task etc. yaddayadda
<abu[m]>
βΊ
<beneroth>
and I think we have this reasonably covered with the nice FFI and CLI wrapping in pil
<abu[m]>
Hunaris doing tests, so it is fine. For production there are probably optimized C-libs available
<beneroth>
same thinking as the microservice proponents use.. allow different languages and specials software but make it work together
<beneroth>
abu[m], true. then again the current hype of python is 1) it's use in teaching 2) the wrappers for the many C-libs that they have available
<beneroth>
pil will not compete on 1) anytime soon. but 2) might be feasible if someone implements those wrappers, should be comparable less work in pil than it was in python to create those wrappers
<abu[m]>
and less parentheses ;)
<beneroth>
then again pil can easily just call the python
<beneroth>
"1958 John McCarthy and Paul Graham invent LISP. Due to high costs caused by a post-war depletion of the strategic parentheses reserve LISP never becomes popular"
<beneroth>
of course they leave out the "German school of lisp"
<abu[m]>
hihi
<beneroth>
I don't remember where I found that sentence aimed at pil, but it was funny :D
<abu[m]>
You responded to that article, somewhen in 2012 or so
<abu[m]>
It recently showed up again in HN
<abu[m]>
last week or so
<beneroth>
oh wow
<beneroth>
so I was looking into pil already in 2012?
<beneroth>
yeah right
<beneroth>
2011 or 2012 I've found pil I think
<abu[m]>
hmm, maybe I'm wrong with that year
<Hunar>
Hi beneroth, the matrix code that I use doesnt use random access (in pil at least), my final goal is for the user to choose pil or something like fortran to see the difference :)
<beneroth>
according to my git I started my first picolisp learning project in Dec 2013
<Hunar>
I have a problem abu my picolisp is inconsistent, same file run multiple times, it crashes in some and runs in others
<beneroth>
Hunar, yes. but the picolisp memory model is random access with everything cells. which is more flexible but not as compact as e.g. binary arrays
<abu[m]>
Heisenbug π
<abu[m]>
What crash is it? Stack overflow?
<beneroth>
Hunar, multiple loads of the same file into the same process (without stopping/starting pil each time) or truly independent runs which fail sometimes?
<beneroth>
do you use namespaces? :D
<Hunar>
run, ctrl-c, run .. I made a video but its very slow to upload
<abu[m]>
Try to 'traceAll' to see where it crashes
<abu[m]>
ah, and a core! So use 'lldb' and then "bt"
<abu[m]>
$ lldb -c core
<abu[m]>
or 'gdb'
<abu[m]>
I prefer lldb recently
<Hunar>
I tried to insgall lldb, my package manager is frozen for some reason
<Hunar>
where is core :/
<abu[m]>
In the working directory where you started the process
<abu[m]>
The video says "core dumped", so I assumed you have "ulimit -c unlimited" set
<abu[m]>
$ find -name core
<Hunar>
Cant find it.. bbl when I find it with google
<Hunar>
found it, its a .zst file (never worked with core dumps before)
<abu[m]>
What is .zst for?
<Hunar>
my core dumps are saved in /var/lib/systemd .. i cleared that folder and ran the program, coredump appeared there. its the only file there has a .zst extention
<abu[m]>
I see
<abu[m]>
Should be fine then
<abu[m]>
So $ lldb -c core, and then "bt" for backtrace
<abu[m]>
The first entry is interesting
<abu[m]>
Often in 'gc'
<Hunar>
"Unable to find process plug-in for the core file"