<JordanBrown>
gbruno hangs out here a lot, but is a really boring guy to talk to.
<JordanBrown>
But his name is good.
<nik>
hi all, how's everyone doin tonight?
nik is now known as Nik
Nik is now known as nik
<JordanBrown>
I'm good, though I was just about to go AFK. kintel and InPhase might theoretically be lurking, but the Germany crowd is presumably in bed.
nik is now known as NikoKun
<NikoKun>
No worries. it's been a while since I've used irc, like decades.. heh
epony has quit [Remote host closed the connection]
<ndnihil>
maybe
epony has joined #openscad
<JordanBrown>
ndnihil: looks like a round-ish cube.
invultri has joined #openscad
<invultri>
Is there a more build in way to do this:https://gist.github.com/christianvdstap/8940e6ab27ef92c81248e7ee3c30c1a9 ?
<invultri>
ah.. that is just a foldl
hyperair has quit [Remote host closed the connection]
hyperair has joined #openscad
<teepee>
it indeed almost looks like a cube in "left" view with a bit of squinting
<JordanBrown>
invultri: more built-in? No. Simpler, yeah, a bit.
<JordanBrown>
teepee you wake up too early.
<teepee>
indeed, trying to decide if I go back for an hour or two or train for next week when I actually have to get up at this time
kintel has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<JordanBrown>
Infinite loop with tail recursion == Bad.
<JordanBrown>
invultri: I put my take on that function as a comment in your gist.
<JordanBrown>
Infinite loop with tail recursion + Automatic Reload and Preview == Particularly Bad.
<invultri>
JordanBrown: not sure what you mean with "automatic reload and preview". head = first of list, tail = rest of list. Yours is probably better since you do not chomp the v down till an empty list.
<JordanBrown>
two independent comments.
<JordanBrown>
sorry
<JordanBrown>
when I was writing mine I had a typo that caused an infinite recursive loop with tail recursion, which in OpenSCAD can be interrupted only by shutting down the program.
<JordanBrown>
So I reloaded the program from the automatic backup, and since it was set for automatic preview, it ran it again and hung again.
<JordanBrown>
Yes, I understood the intent of head() and tail(), but there are no such built-in functions.
<JordanBrown>
And yes, you definitely do not want to chomp down the list.
<invultri>
comment added with the missing things
<invultri>
JordanBrown: yes... once upon a time there was this stop button but that got removed again in case you went infinite recursion. Usually it means going to vi and undoing the change.
<JordanBrown>
For head and tail, if you explicitly specify the step as 1 (e.g. n:1:N-1) then you shouldn't need the test and explicit [].
<JordanBrown>
[2:1:1] will execute zero times and yield your empty list.
<invultri>
ain't that a warning however?
<JordanBrown>
no
<JordanBrown>
At least I don't think it is. Checking.
<JordanBrown>
huh, so it is. I swear that I've done that many times before.
<JordanBrown>
looking around some more.
<invultri>
it says it is "deprecated" so it probably was fine once
<JordanBrown>
ah, it's a warning if the values are constants.
<JordanBrown>
The deprecation warning is for begin>end without an explicit step.
<JordanBrown>
because that runs the loop backwards.
<JordanBrown>
sorry, no, it doesn't, it just silently swaps them.
<JordanBrown>
So if you might need to yield an empty list, you have to explicitly say :1: in the middle.
<JordanBrown>
Or :-1: if you're counting down.
<JordanBrown>
For the special case of adding up all of the values, I suspect that the fastest answer is
<invultri>
the more I learn. looks like that 6am was a good time for fp
<JordanBrown>
function vsum(v) = v * [ for (i=v) 1 ];
<JordanBrown>
Not that it often matters exactly how fast such a thing is.
<JordanBrown>
But anyhow, for that accumulate function stepping across is simpler and faster.
<JordanBrown>
And the pattern for it is simple enough that although I've written a general function like accumulate once or twice before, I've never bothered to keep it around. I just write the appropriate recursive function each time.
<JordanBrown>
I'm kind of surprised that BOSL2 doesn't offer a general function like accumulate.
<invultri>
well it is also my mistake for not identifying it as a foldl
<JordanBrown>
One of the BOSL2 guys, Adrian Mariano, discovered that if you can reformulate your problem into being a matrix multiply, that's almost always the right answer.
<JordanBrown>
But he is a lot better at reformulating things into matrix multiplies than I am.
<invultri>
I suck at matrixes for some reason. I should work to a first grade matrix book sometime. I do understand their usefulness, but if I can't use the tool ...
arebil has joined #openscad
<JordanBrown>
Time for me to more or less shut down for the night.
<invultri>
and I have to head to the dayjob ;) thanks for the chat