IRC channel logs

2015-01-26.log

back to list of logs

<Zerock>How does one get "argv" in Guile?
<taylanub>Zerock: (info "(guile) Runtime Environment")
<taylanub>`program-arguments' or `command-line'
<mark_weaver>Zerock: my favored way to get pi is (acos -1)
<Zerock>mark_weaver: I didn't think of acos. Yep.
<taylanub>the manual is pretty well organized; e.g. I quickly found that Info node by following 7. Guile Modules -> 7.2 POSIX
<davexunit>mark_weaver: didn't think of that, either. thanks!
<davexunit>I'll change the definition in Sly.
<Zerock>Sly?
<Zerock>Is that a program? A library? Document?
<mark_weaver> https://gitorious.org/sly/sly
<davexunit>thanks mark_weaver
<mark_weaver>np! :)
***petercom1and is now known as petercommand
<nalaginrut>morning guilers~
<nalaginrut>ArneBab: I've asked RMS, he said he maybe misread the context so that he thought asm.js is a nonfree VM for js. I explained asm.js is a spec for a special JS expr, so I think compiling to asm.js would be a cool way to try for free software
<cluck>nalaginrut: the only sad thing about asm.js is the main compiler (emscripten) being llvm based not gcc based
<nalaginrut>cluck: yes, but it's possible to have asm.js backend in free compilers
<cluck>nalaginrut: go for it, it'd be great to have guile everywhere.
<nalaginrut>cluck: well, it's better to have x86 native AOT first
<nalaginrut>cluck: after all, asm.js spec is still experimental
<nalaginrut>I'd recommend don't try too cutting-edge things, even Artanis changed APIs three times before the first release...
<nalaginrut>fortunately it's released...
<cluck>only the low level optimizations, other than that it's really just standard javascript/ecmascript
<cluck>(you can run anything compiled down to asm.js in any standards respecting browser, it just might run slow)
<nalaginrut>yes, it's actually JS itself, but as a spec, it's better to follow the same define in all compilers. Or we should define out GNU asm.js
<nalaginrut>I'm afraid it could be changed in the future version
<nalaginrut>I mean the instr define
<nalaginrut>s/out/our
<ArneBab>nalaginrut: thanks a lot!
<nalaginrut>ArneBab: np ;-)
<ArneBab>nalaginrut: I hope that can make it easier for GCC to include an asm.js backend.
<nalaginrut>yeah, I wish someone could do that work, of course it's possible for Guile too
<ArneBab>yes
<ArneBab>nalaginrut: https://twitter.com/ArneBab/status/559618179325235200
<nalaginrut>ArneBab: yeah, thanks for asking it, I'd like to see they write it
<ArneBab>nalaginrut: same for me ☺ — I assume that this is the least effort way to throw in the main argument, that game programming companies have to try asm.js, so GCC needs a backend to avoid being put out of the loop.
<ArneBab>nalaginrut: I personally think that asm.js will be essential, because it reduces the effort to try a game from multiple clicks to “just open a URL”.
<nalaginrut>ArneBab: considering the Doom demo under asm.js performances well, I really want to play games easier on Linux
<ArneBab>yes — from what I hear, asm.js can get about half the speed of native code.
<ArneBab>and Good old Games would be thrilled, I guess ☺ (all those great games for which the current computers are massively overpowered)
<nalaginrut>it's interesting, since VM will get 1/10 speed in general, but JS got very good optimization IMO
<nalaginrut>ArneBab: If Linux can's solve gaming issue, there'll be more people use it
<nalaginrut>s/can's/can
<nalaginrut>when I choose to remove Win in my machine many years ago, I have to buy console for gaming...
<nalaginrut>of course, consoles are extreme proprietory softwares.
<civodul>Hello Guilers!
<ArneBab>nalaginrut: I mostly stopped gaming - and more importantly music production - when I switched to GNU/Linux (from MacOSX). Nowadays I sometimes play on handhelds.
<nalaginrut>anyway, pure free software makes me learn more things, I won't be disturbed by entertainment in my PC
<nalaginrut>civodul: heya!
<ArneBab>sidenote: I got a short review from one of the SRFI editors on my wisp draft. I already addressed it, so I hope it will land as official draft SRFI soon *happy*
<ArneBab>Hi civodul
<nalaginrut>ArneBab: speaking music production, we've built a band in our local community. I've tried to make our own music with pure free software. But it seems hard
<ArneBab>nalaginrut: I sometimes try out free software games, but I’m missing the genre I love most (RPGs).
<ArneBab>nalaginrut: nice! Making music with pure free software can work well, but you need to tune your setup.
<nalaginrut>We're not expertise on producing music, and it lacks good document for these free music producing software
<ArneBab>nalaginrut: audacity is great, but in recent years I ran into grave problems (recording breaking)
<ArneBab>nalaginrut: I guess you’ll need to setup jack for anything which should be live.
<ArneBab>nalaginrut: if it’s a garage band, you might succeed with buying a USB pre-amplifier (ensure that it works with GNU/Linux!) and just cutting stuff on audacity.
<nalaginrut>ArneBab: there're too many things beyond my mind, someone stick to use a proprietory software for drum composition
<ArneBab>sadly all the music software I found (except for audacity) lacked the polish I need for creative work: They all got in my way.
<nalaginrut>well, it's too professional for me ;-(
<nalaginrut>yes, I'm not expertise on music composition, I feel it's complicated than a compiler ;-D
<ArneBab>nalaginrut: maybe hook up with some of the music professionals in the Gentoo forums: http://forums.gentoo.org/viewforum-f-33.html
<ArneBab>music composition needs undisturbed thinking…
<ArneBab>but then, the composition isn’t part of the final work. You could for example do the sheet music with lilypond.
<nalaginrut>oh~seems a good place to follow
<ArneBab>http://gentoostudio.org/ — just saw that there
<nalaginrut>nice, fav it
<nalaginrut>yes, I wish someday I could try lilypond, as a Guile fan, I never tried lilypond ;-P
<ArneBab>nalaginrut: lilypond is pretty cool, but sadly I still didn’t get it to work with guile 2.0.x
<nalaginrut>oh
<ArneBab>here’s how infinite hands looks in lilypond: http://infinite-hands.draketo.de/infinite_hands_sheet.ly (source for http://infinite-hands.draketo.de/infinite_hands_sheet.pdf and http://infinite-hands.draketo.de/infinite_hands_sheet.midi)
<nalaginrut>oh, nice~
<ArneBab>nalaginrut: one pretty useful property is that I can create the midi and play it with timidity to see whether I really got the music right :)
<ArneBab>(but you get that with any composer package today)
<nalaginrut>fortunately, we have a keyboard with midi interface in our hackspace. Will try it someday~
<nalaginrut>these days are too busy, you know, the Chinese new year is coming
<ArneBab>to get the best of both worlds, you can try denemo - it uses lilypond as backend: http://www.denemo.org/
<wingo>moin
<ArneBab>moin wingo
<nalaginrut>wingo: morning
<nalaginrut>ArneBab: nice things~first time know it, thanks!
*nalaginrut fav it
***petercommand is now known as petercommand_
***petercommand_ is now known as petercommand
<zacts>hi guile geeks
<zacts>ArneBab: I need to try out lilypond again
<zacts>oh, let me link something here
<zacts> http://player.oreilly.com/videos/0636920030423?toc_id=152786
<zacts>^ I want to do something like this with lilypond
<zacts>for musical composition
<zacts>via programming
<daviid>hello guilers!
<ArneBab>zacts: that would be pretty nice, I think. It would have the advantage of producing high quality sheet music, too.
<wingo>hello daviid
<daviid>hello wingo
<daviid>wingo: did you have a chance to look at the goops setters inheritance bug?
<wingo>daviid: no, did you produce a reduced test case? :)
<daviid>i did and posted it here :)
<daviid>let me post again
<wingo>a case without guile-gnome
<daviid> http://paste.lisp.org/+345W/2
<wingo>good, tx
<daviid>this problem gives me headhakes :) ping me when you have something... tx!
<wingo>lol
<saul>I'd like to present a coding challenge: given a list of numbers, return a list mapping the sum of the products of each element and all the other elements.
<saul>So given the list (2 4 6), the result would be:
<saul>(list (+ (* 2 4) (* 2 6)) (+ (* 4 2) (* 4 6)) (+ (* 6 2) (* 6 4)))
<please_help>(fold * (map (lambda (x y) (+ x y)) lst (cdr lst))) maybe?
<please_help>@saul
<saul>please_help, I will test that, thanks.
<please_help>actually it should be (fold * (map (lambda (x) (map (lambda (y)) (+ x y)) lst) (cdr lst))) I think
<please_help>without the missing parens of course
<mark_weaver>(lambda (xs) (let ((sum (fold + 0 xs))) (map (lambda (x) (* x (- sum x))) xs)))
<mark_weaver>saul: ^^
<saul>mark_weaver, that looks correct. :)
<mark_weaver>:)
<saul>Now I have to figure out how to apply it to my *real* goal, which is to compute the sum of the distances between points on a sphere with all of the other points.
<mark_weaver>saul: can you state that more clearly?
<mark_weaver>by "all of the other points", do you mean an infinite set?
<saul>mark_weaver, it is a fixed number of points. The ultimate goal is make all points equidistant from each other (as much as possible).
<mark_weaver>ah
<saul>Here is a BASIC program that does something quite similar: http://www.math.niu.edu/~rusin/known-math/95/sphere.bas
<mark_weaver>wow, basic. it's been a long time since I looked at a basic program
<mark_weaver>it was my first programming language. fortunately, I discovered pascal not long after, or else I might never have recovered.
<mark_weaver>(this was circa 1980)
<saul>mark_weaver, I don't think will be able to use your "(- sum x)" approach because the "distance" function is not distributive IOW: while a*(b + c) == a*b + a*c , Substituting my distance formula for the multiplication is not the same.
<mark_weaver>correct
<saul>Both of you have given me things to investigate. So thanks.
<mark_weaver>saul: so I guess it would be helpful to have a working answer to your original challenge that did not make use of that trick.
<ArneBab>saul: this one is less elegant, but works: http://paste.lisp.org/display/145388
<ArneBab>(uses srfi-42)
<mark_weaver>ArneBab: that assumes that the list elements are all distinct.
<ArneBab>mark_weaver: ah, yes…
<mark_weaver>it's also not written in scheme :-P
<mark_weaver>(well, not standard scheme lexical syntax)
<ArneBab>
<ArneBab>I can change that in an instant ☺
<ArneBab>(the SRFI already reached the editors)
<mark_weaver>ArneBab: but I'm glad to see you willing to use some parens. I remember not liking the results of trying to *minimize* the number of parens at all costs.
<ArneBab>this one is in pure scheme syntax: http://paste.lisp.org/display/145388#2
<ArneBab>mark_weaver: where the parens are not directly inferrable from indentation I don’t mind using them.
<ArneBab>it’s just the parens I consider as superfluous which I want to get rid of (the ones I have to remember to close after the procedure definition)
<saul>I'm going to have to research eager comprehension. :)
<mark_weaver>but yeah, the assumption that all the list elements are distinct might be a problem.
<ArneBab>saul: I like that a lot
<ArneBab>mark_weaver: I might have to iterate over the range, not the numbers, and use list-ref.
<ArneBab>but that could be slow…
<mark_weaver>saul: http://srfi.schemers.org/srfi-42/srfi-42.html
<mark_weaver>it would be very slow, yes.
<mark_weaver>list-ref takes time proportional to the index
<saul>What do you guys mean by all the list elements being distinct?
<mark_weaver>right now, the algorithm saul is trying to implement takes O(n^2) per iteration, which is bad enough. using list-ref would make it O(n^3).
<mark_weaver>saul: (2 4 6) has distinct elements. (2 2 6) doesn't.
<saul>mark_weaver, correct.
<mark_weaver>ArneBab's solution doesn't work for lists like (2 2 6)
<ArneBab>mark_weaver: n^3 - yikes!
<mark_weaver>one solution is to use vectors instead of lists, and (srfi srfi-43) may help there.
<ArneBab>I remember implementing a “distance from all others” myself. It quickly gets costly.
<mark_weaver>when using lists, the first idea that comes to mind is this: while iterating over the list, maintain a (reversed) list of the elements you've already iterated over. then, that reversed list plus the cdr makes "all the other elements"
<ArneBab>saul: I assume that the elements will form a sphere, right?
<saul>mark_weaver, that is how I was originally attempting it.
<ArneBab>saul: are you working in 2D or 3D?
<saul>ArneBab, the elements are points on a sphere. Currently specified in cartesian coordinates. So my list will actually be something like ((x0 y0 z0) (x1 y1 zy) ...)
<mark_weaver>technically, the points are in a 2 dimensional space, but that space is not euclidean.
<ArneBab>saul: ah, and you want to move them on the sphere to get an even distribution?
<mark_weaver>but I suppose it's convenient to embed that sphere in 3d space.
<mark_weaver>ArneBab: it's all explained in the comments of that basic program saul linked to. basically, it sort-of simulates charged particles constrained to lie on the surface of a sphere, so the particles all repel each other.
<saul>Arnebab, yes. Say I start by placing five points around the equator. Then I would put 5 points around the 45-degree latitudes (both above and below the equator) and then two points at the poles (total of 12 points).
<ArneBab>in that case, it should be possible to subdivide the problem: just work on every tenth (or xth) element first, balance these individually and only do the full cost calculation in the end.
<ArneBab>(just in case you want to do this for really many points)
<saul>This is the starting point. I then would compute the sum of the distances between each other and make adjustments to the point coordinates to eventually maximum that sum.
<saul>ArneBab, I am not too concerned about speed. I think I will only need about 50 to 100 points.
<saul>(That's still tens of thousands of calculations, but should be tolerable.)
<lloda`>do you need the points to be randomly distributed? because if you don't care about that, there're ways to produce uniform arrangements outright. And if you only want < 100 points you can just download tables of optimal points from the web...
<ArneBab>I just realized that my version could be much easier…
<saul>lloda, I would prefer to do it algorithmically. I started with the idea of placing letters around a sphere and wanting to have the letters not overlap and to have them fairly evenly distributed.
<saul>But then I started yak shaving the mathematics of it all.
<ArneBab> http://paste.lisp.org/display/145388#3
<ArneBab>instead of removing the number from the list of numbers, we can simply substract it later
<ArneBab>saul: it’s still not as single-line elegant as the example from mark_weaver, but I understand it much faster…
<saul>ArneBab, unfortunately that won't work for my actual use-case, which does not obey the distributive property of multiplication.
<saul>At least, I'm pretty sure it doesn't.
<ArneBab>it does obey the distributive property of addition, right? (it’s in the addition in which the element is removed later)
<saul>ArneBab, I will investigate that. My first thought was that I could subtract the distances because the formula was non-linear (the sqrt of the sum of the squares). But maybe you are correct.
<saul>s/could subtract/could NOT subtract/
<saul>ArneBab, I am going to read up on comprehensions. I don't really understand your code.
<saul>Here is the code I had from porting the BASIC code: http://pastebin.com/R4eQXwZX
<saul>It uses separate lists for the x, y, and z coordinates of the points. Instead, I am now using a single list of points (each point being a list of the three coordinates).
<dsmith-w`>Monday Greetings, Guilers
***dsmith-w` is now known as dsmith-work
<ArneBab>saul: the code might be longer, but I’d just stick to your code: It’s very clear what you do.
<ArneBab>saul: the only change I would do is to add d as a parameter of the loops and get rid of the set!
<ArneBab>saul: something like this: http://pastebin.com/3AJSAiES
<ArneBab>(coded in-browser without checking anything, so beware the bugs ☺)
<saul>ArneBab: here is what I have (converted to a list of points as well): http://pastebin.com/YQD9xYKd
<wingo>sneek: later tell daviid the answer to your issue will not make you happy :)
<sneek>Okay.
<wingo>sneek: later tell david turns out the fix to #17355 was wrong; that really accessor methods aren't meant to be "chained"
<sneek>Will do.
<stis>hej guilers!
<davexunit>would be cool to have a version of this written in guile https://github.com/ariya/phantomjs
<davexunit>scriptable, headless webkit. too bad you have to use javascript to do the scripting ;)
<davexunit>though given the DOM stuff it can do, maybe JS is the only damn option.
<wingo>meep meep
*davexunit puts on coyote costume and purchases ACME products
<stis>hej wingo: great progress with 2.2
<wingo>tx!
<wingo>is it working for you stis?
<stis>guile-log and prolog works just like a charm
<stis>that's a pretty complex application and a good stress test
<stis>when do you think a release is appropriate?
<stis>it is working like a charm ontop of master
<wingo>dunno, a prerelease can happen any time
<wingo>i guess i should update NEWS for changes since the last time I updated NEWS
<wingo>then see if distcheck passes :P
<stis>cool!
<davexunit>would this be a 2.1 unstable release?
<stis>I really think it's a good idea to pre release it, too many goddies to leave hidden in master
<davexunit>it would be nice to read an updated NEWS file. I only know of the general big changes: new vm, new compiler.
<stis>don't forget huge stacks at will davexunit:
<stis>and a faster VM
<davexunit>oh yes, no more stack overflows.
<davexunit>sort of...
<stis>well yes, if you have a bug there is no escape.
<davexunit>that's what I'm worried about.
<davexunit>but it is nice to be able to write things the naturally recursive way
<davexunit>rather than writing an iterative solution and having to do something like call 'reverse' on the resulting list.
<stis>be careful there is a compression factor using tail calls
<zacts>hi
<zacts>new vm for guile?
<davexunit>stis: what do you mean be compression factor?
<stis>if you have a lot of stale local variables in the stack frame and don't get rid of them at the call
<stis>you can consume space
<davexunit>I understand that it is preferable to use tail calls, but for procedures like 'map', using TCO results in an uglier implementation.
<stis>true
<stis>just use the feature with care. And many times there is no option to do tail calls
<davexunit>there's a procedure to set an arbitrary stack limit
<stis>I've got plenty of experience rewriting nice looking code into a difficult mess just because the stack is small!
<davexunit>so I guess I'll try to use that
<stis>yeah at least when debugging and initial coding it can be nice to control the stack limit
<stis>to a low value
<davexunit>I just worry about the unbounded memory growth if you fuck up.
<stis>yep, but also snappier when there is a bug, and you catch memory hogs early
<davexunit>people would give guile a lot of flak if someone's guile application ate all of their RAM while they weren't looking.
<davexunit>and then proceeded to eat the swap, too.
<wingo>davexunit: yeah unstable
<stis>I'm a bit sloppy using 2.2 with no explicit limit given
<stis>it did chake the system a few times but no severe hickups
<davexunit>I'm curious what the performance difference is for something like 'map'.
<wingo>davexunit: test it
<zacts>I should check on the boehm gc musl patches
<davexunit>wingo: sure. I just don't have guile master available to me to atm on my work machine. that will be a test to run later.
<stis>,time (let lp ((n 1000) (f f)) (if (> n 0) (lp (- n 1) (map (lambda (x) (+ x 1)) f))))
<stis>;; 0.762857s real time, 0.785571s run time. 0.202775s spent in GC.
<stis>scheme@(guile-user)>
<zacts>I would love to test building guile with musl
<stis>,time (let lp ((n 1000) (f f)) (if (> n 0) (lp (- n 1) (map (lambda (x) (+ x 1)) f))))
<stis>;; 1.124487s real time, 1.122900s run time. 0.166353s spent in GC.
<stis>The faster one is master a weak ago
<stis>(define f (iota 10000))
<stis>and now for (define (m f x) (if (pair? x) (cons (f (car x)) (m f (cdr x))) '()))
<stis>,time (let lp ((n 1000) (f f)) (if (> n 0) (lp (- n 1) (m (lambda (x) (+ x 1)) f))))
<stis>;; 0.837108s real time, 0.858177s run time. 0.206458s spent in GC.
<stis>on 2.2, it segfaults on 2.0
<stis>so pretty much the same time on 2.2
*davexunit thinks about using parameters as the basis for abstracting changes in OpenGL state.
<davexunit>seems to map fairly well since OpenGL state is thread-local.
***wleslie_ is now known as wleslie