IRC channel logs

2020-12-05.log

back to list of logs

<fnstudio>hi, i was experimenting with some (very basic!) scheme and wrote this https://paste.debian.net/1175655/
<fnstudio>i was expecting it to terminate when it gets to 100, but it does not
<fnstudio>my (clearly mistaken) expectation is based on some (only apparently) similar pattern that i've seen elsewhere
<fnstudio>ah, no, wait, i think i see it now... it never leaves the recursion
<mwette>misplaced paren maybe the (counter ....) should in the (if ...)
<mwette>(if (> ...) '() (counter ...))
<fnstudio>mwette: true!
<fnstudio>thanks!
***amiloradovsky1 is now known as amiloradovsky
<RhodiumToad>so I did another attempt at that cartesian product macro, using only syntax-rules
<RhodiumToad> https://dpaste.org/pqhr
<RhodiumToad>I'm pretty sure this doesn't have the memory allocation issues of the previous attempt.
***srandon111 is now known as suchablyat
***suchablyat is now known as sookablyat
<daviid>weinholt: (and any guile-lib users) hello! I pushed 4 patches to guile-lib devel branch, so make distcheck pass with both 2.2 and 3.0.4
<daviid>I didn't solve the deprecated related msg yet, nor the other 'unbound variable c warnings' (as it appears in 2.2 'as is' as well
<daviid>there are quite a few additional warnings running make (when building the doc) while using guile-3.0, but make distcheck pass - so, please feel free to check, clone and checout the devel branch ... when everything is proved ok, i could merge to master, bump to 0.2.7 and release
<sookablyat>what's the use of most commonly used ssrf ?
<sookablyat>i can't wrap my head around this guys
<leoprikler>sookablyat: did you mean srfi?
<leoprikler>RhodiumToad: magic
<tohoyn>sneek, botsnack
<sneek>:)
<fnstudio>hi i'm having some troubles with a case statement, here https://paste.debian.net/1175708/ if anyone has the time to give a look
<fnstudio>the underlying problem is that i'm not sure i've a clear understanding of the way strings and expressions are handled
<fnstudio>so, there's something that's printed on the screen as `abc` but then apparently that doesn't match with `abc` in a case statement
<fnstudio>but i'm having similar problems beyond case-statements so i must be missing some understanding
<fnstudio>updated version https://paste.debian.net/1175709/
<fnstudio>ok, i think i see what the problem is or what it is related to at least
<fnstudio>`(equal? key "number")` returns true
<fnstudio>but `(eqv? key "number")` returns false
<fnstudio>i suppose case uses eqv? instead of equal?
<tohoyn>fnstudio: What is the value of 'item'?
<tohoyn>fnstudio: according to R6RS 'case' uses 'eqv?'
<fnstudio>tohoyn: item has form `(number 42)`
<fnstudio>tohoyn: `number`, in particular, is shown as above, with no quotes
<fnstudio>however, if i display (string? key) i'm told it's a string
<fnstudio>(and thanks for confirming case uses eqv?)
<fnstudio>so i guess i now have two questions: the first is whether there's a common pattern to use case with a different equality
<tohoyn>fnstudio: define an own macro for that
<fnstudio>the second would be about investigating why key and "number" are not reported as eqv but only as equal
<fnstudio>tohoyn: ok, thanks, i'll try a macro
<tohoyn>fnstudio: eqv? returns #t for two strings if the strings are the same object, i.e. they have the same address
<fnstudio>tohoyn: wasn't that eq?
<tohoyn>fnstudio: both eq? and eqv?
<tohoyn>fnstudio: see R6RS section 11.5
<fnstudio>tohoyn: oh ok, i see, thanks
<tohoyn>The debianized version of g-golf gives the following error with test-case test-g-property-object: FAIL: tests/hl-api.scm
<tohoyn>Unable to init server: Yhdistäminen ei onnistunut: Yhteys torjuttu
<tohoyn>(guile:10754): Gtk-WARNING **: 12:34:21.150: cannot open display:
<tohoyn>sorry for flooding
<tohoyn>error message in English: "Connecting did not succeed. Connection rejected."
<tohoyn>all the tests work fine when run normally (not building a Debian package)
<fnstudio>and might there be a way of reducing two strings to a canonical form so that they result eqv? (not just equal?)
<tohoyn>fnstudio: what should the reduction return if the strings are not equal?
<fnstudio>tohoyn: what i mean is that the strings are equal? but reported as not eqv? (probably for the reason you explained above); i was wondering if there's a way to reduce both strings to a third "thing" so that they'll then be reported as eqv?
<fnstudio>i'm not sure i'm making sense, sorry
<tohoyn>I tried to build the Debian package with debuild. I suppose it does not use a chroot environment.
<tohoyn>fnstudio: (if (equal? str1 str2) str1 ...)
<fnstudio>tohoyn: yeah, i'm probably overcomplicating it, i suppose i can switch to an if-statement and use equal? straightaway
<tohoyn>fnstudio: I suggest using a hash table with equality predicate 'equal?'.
<fnstudio>i just thought there might be an idiom to do this with case
<tohoyn>fnstudio: when you use hash-ref for that kind of hash table you always get the same object for two identical strings
<fnstudio>ok, thanks tohoyn i'll look into it
<tohoyn>see section 6.6.22 in the guile 2.2 info pages
<fnstudio>cool, more in general, you mentioned R6RS above, what do you think my points of references should be when learning scheme? http://www.r6rs.org/ ? together with the guile docs?
<tohoyn>fnstudio: R6RS is the most important document. You should also look at R7RS.
<fnstudio>excellent, thanks, v helpful
<tohoyn>does anybody have an idea why GTK can't open a display?
<tohoyn>could it be missing X server?
<tohoyn>fnstudio: BTW, look at http://tohoyn.fi/theme-d/index.html
<tohoyn>fnstudio: Theme-D is a strongly typed language resembling Scheme
<fnstudio>tohoyn: impressive, thanks
<RhodiumToad>leoprikler: do you mean that in a good way or a bad way? :-)
<leoprikler>both kinda
<leoprikler>it's nice to have this in pure syntax-rules, but the let-bindings are super confusing if you don't know what Scheme does to keep them hygienic
<tohoyn>daviid: could you help me with the failing test case?
<RhodiumToad>leoprikler: this seemed to me to be a case where the hygienic stuff could be used to advantage
<RhodiumToad>so, yes, the inner call ends up as (proc i i i) or whatever, but the i's are different bindings (and this is visible if, for example, you decompile the tree-il back to scheme)
<leoprikler>a good example for why macros should wash their hands and wear masks :)
<tohoyn>daviid: the problem is that gtk-init fails to make a connection
<fnstudio>i have this long chain of if-s that i would like to transform in a case statement
<fnstudio>the main reason for that is that i'd like my procedure to return the value provided by the first matching if statement
<RhodiumToad>what are the conditions?
<fnstudio>say if key is aaa do this, if key is bbb then do that
<fnstudio>in a long series
<fnstudio>but i'd like it to terminate as soon as key is matched with, say, aaa
<RhodiumToad>you can use case as long as all the conditions are (eqv? key someconstant)
<euandreh>case does terminate
<fnstudio>i don't seem to be able to use case because of its reliance on eqv? as opposed to equal? - at least i think that's the issue there
<RhodiumToad>if the conditions are more general, then cond rather than case would be the thing to use
<fnstudio>RhodiumToad euandreh, ok, cool, that's great, i'm going to give cond a try then
<fnstudio>thanks!
*RhodiumToad first learned lisp on an implementation where cond was literally the only conditional construct, so tends to use it fairly often
<leoprikler>if conditions are really dire, you should try ice-9 match
<leoprikler>RhodiumToad: now you know how to implement case in terms of cond :)
<sookablyat>RhodiumToad, i learned lisp on a dragonflybsd on powerpc64le where i had to code my lisp interpreter in powerpc assembly
<RhodiumToad>I admit to not having coded the interpreter myself.
<RhodiumToad>but it was on a 6502 cpu with 32kB of ram
<spk121>.
<sneek>Welcome back spk121, you have 1 message!
<sneek>spk121, leoprikler says: the documentation for scheme bindings has apparently been merged
<sookablyat>RhodiumToad, meh
<sookablyat>RhodiumToad, start to hack with the DragonFly on A powerPC dude
<sookablyat>you will discover the wonders of using a REAL unix
<mwette>RhodiumToad: that looks promising but when I copy and try to run I get: Unbound variable: #{\x200b;}#
<spk121>mwette: #x200b is ZERO WIDTH SPACE (U+200B) which usually means that you copied an HTML line break or something like that
<mwette>Got it now. The display had some junk.
<mwette>RhodiumToad: Clever. Looks nice.
<mwette>sneek: later tell RhodiumToad That looks nice. Clever job!
<sneek>Will do.
<mwette>spk121: thanks
<mwette>I didn't have javascript enabled for dpaste.org. Enabled, now the copy works.
<mwette>sneek: later tell RhodiumToad I need a fold also: (cartesian-fold proc 1 '(a b c) '(d e f) '(g h i)) -- I will take a shot but you might get it faster.
<sneek>Got it.
<daviid>sneek: later tell tohoyn I am afraid I can't help you, it is a debian 'package building environment' problem, which I know nothing about, but it appears that the building environment does not to have a X11/Wayland server available, hence gtk-init fails ... you should ask for help to 'debian', maybe #debian-next (irc.oftc.net), might help or suggest 'where' to ask ...
<sneek>Got it.
<fnstudio>hi, can anyone suggest an obvious "translation" of python's group-by to guile? (i'm not even sure the question makes sense, maybe i'm supposed to use a particular idiom/pattern instead of a function)
<ArneBab>fnstudio: what do you mean by group-by?
<fnstudio>ArneBab: i have a list of pairs and would like to group them together, depending on one of their elements
<fnstudio>actually, i'd be fine in just counting them, i.e. how many there are for each coordinate x (suppose the pairs are (x, y))
<ArneBab>do you mean something like '((1 . 2) (1 . 5) (2 . 4) (1 . 3)) to '((1 2 5 . 3) (2 . 4)) ?
<fnstudio>ArneBab: i was thinking of '(1 . 1)(1 . 2)(1 . 3)(2 . 1)(2 . 2) to '(1 . (1 2 3))(2 . (1 . 2))
<fnstudio>(not sure if i got the formatting right though)
<ArneBab>that’s what my version boils down to, only with less overead :-)
<fnstudio>ah... cool
<fnstudio>sorry :)
<ArneBab>no problem :-)
<ArneBab>Scheme is typically somewhat more low-level than Python, or rather more abstract
<ArneBab>and there might be things I miss
<fnstudio>yeah it looks great, i find it very interesting for that reason
<fnstudio>but there's so much i've got to learn
<ArneBab>maybe I can save you some time with this: http://www.draketo.de/py2guile
<ArneBab>it’s not complete and 2-3 years out of date on my own progress, but it should get you over the initial bumps
<fnstudio>that's fantastic!
<fnstudio>"You must unlearn what you have learned" :)
<fnstudio>(may i ask if you're the author?)
<ArneBab>I am, yes — and I’m glad you like it :-)
<fnstudio>great stuff, thanks, i'll let you know how it goes with that
<ArneBab>thank you!
<ArneBab>fnstudio: you might be able to do something elegant with a map
<ArneBab>or reduce
<ArneBab>One more hint that I learned after py2guile: Use info (standalone or info-mode in Emacs) and look for tools with full-text-search.
<ArneBab>fnstudio: how much efficiency do you need? Is memory an issue?
<fnstudio>ArneBab: i was able to find a quick and dirty solution - for now
<ArneBab>(define (assoc-increment! key alist)
<ArneBab> "Increment the value of the key in the alist, set it to 1 if it does not exist."
<ArneBab> (define res (assoc key alist))
<ArneBab> (assoc-set! alist key (or (and=> (and=> res cdr) 1+) 1)))
<ArneBab>(fold assoc-increment! '() (map car xydata))
<ArneBab>(define xydata '((1 . 1)(1 . 2)(1 . 3)(2 . 1)(2 . 2)))
<ArneBab>fnstudio: this should do the counting
<fnstudio>ArneBab: this is amazing
<fnstudio>ArneBab: thanks, efficiency is not a major concern, it's more using this an excuse to get a bit more familiar with guile
<fnstudio>which includes the fact that i want to improve, therefore also aim for efficiency, but it's not top priority
<ArneBab>sounds great!
<fnstudio>ArneBab: thanks for your snippet - i'm going to save it and study
<ArneBab>I’ll put it on my site — that’s an issue that will come up more often. In Python I’d have used collections.Counter
<fnstudio>thanks for the tips about reduce and emacs/info as well, by the way, i didn't miss those as well
<ArneBab>glad to help :-)
<ArneBab>Have fun on your path to Guile!
<ArneBab>fnstudio: https://www.draketo.de/software/guile-snippets.html#org3f2212c
<fnstudio>it's very rewarding; i really wish i had encountered lisp earlier in my life
<fnstudio>wow, that was quick! :) well done
<ArneBab>would you like to be referenced as person who asked?
<fnstudio>ArneBab: well, i'm totally happy with that, but i feel i have contributed so little! :)
<ArneBab>Asking a question at the right time is a skill of its own :-)
<fnstudio>ArneBab: feel free to reference my name and this bit of the chat (if logged) if you like, but don't feel obliged
<fnstudio>:)
<ArneBab>the name fnstudio is ok? (that’s all I see from you)
<fnstudio>yes, fnstudio is fine
<ArneBab>thanks :-) — will be updated in a few minutes