IRC channel logs

2021-10-02.log

back to list of logs

<RhodiumToad>honestly this is a very poorly organized universe
<morganw>Possibly an annoying beginner question (apologies), but if two modules both have procedures with the same name is the only (or best) option to use a renamer when importing?
<RhodiumToad>if you need to use both in the same module, yes
<morganw>thanks!
***chris2 is now known as chrislck
<stis>o/
<fnstudio>hi, given an array, is there a simple/smart way to iterate over its elements while maintaining awareness of each element's coordinates?
<chrislck>what's an array
<fnstudio>chrislck: core arrays, https://www.gnu.org/software/guile/manual/html_node/Arrays.html
<fnstudio>i can think of a convoluted way that involves creating a second ad-hoc matrix for storing indexes and then using some variation of array-index-map!
<fnstudio>but that doesn't feel very clean
<chrislck>ah i don't use arrays. you'll probably use for-each while keeping an internal (index++ mod ncols)
<fnstudio>chrislck: ah i see, ok, for-each will be then - thanks!!
<RhodiumToad>manually tracking the indices seems fragile
<fnstudio>RhodiumToad: hm, i wonder if i should consider switching to a different data structure?
<fnstudio>RhodiumToad: or do you know of a recommended way of doing this directly from arrays?
<fnstudio>here's my problem, in a nutshell: given an array with elements #f and #t, i'd like to get a list of all coordinates of #t elems
<RhodiumToad>do they have to be in order?
<fnstudio>no, that's irrelevant i think
<RhodiumToad>you could use array-index-map! with a dummy destination array
<fnstudio>yeah, is the idea that the dummy array should be of the form (i, j) for every (i, j)?
<RhodiumToad>no, just fill it with #f
<fnstudio>oh, ok... thinking
<fnstudio>oh and then proc will be identity?
<fnstudio>the proc provided to array-index-map!, i mean
<RhodiumToad>no
<RhodiumToad>actually you don't need a dummy array
<RhodiumToad>(let ((res '())) (array-index-map! ary (lambda args (let ((elt (apply array-ref ary args))) (when elt (set! res (cons args res))) elt))) res)
<fnstudio>oh wow!
*RhodiumToad finds the mutation somewhat obnoxious
<fnstudio>thanks RhodiumToad, let me absorb that :)
<RhodiumToad>what's needed is an array-index-fold or similar
<fnstudio>thanks RhodiumToad, that solved my problem
<fnstudio>:)
<RhodiumToad>I don't think it's very efficient, if you plan on doing it a lot, might be better to consider another data structure
<lampilelo>or write a c module with new functionality for arrays
<fnstudio>ok, good to know, thanks RhodiumToad
<fnstudio>lampilelo: hm too much work for the current task, but good to know that that's also an option
<chrislck>fnstudio: I meant array-for-each initially
<Zelphir>Hello! I accidentally posted a question in #guix a minute ago, which I wanted to post here. Sorry for that. So here we go:
<Zelphir>So I got the following code: https://paste.debian.net/1214099/ and I am wondering what I am doing wrong. I have also put the strack trace displayed by Geiser using ,bt and a trace displayed by Geiser using ,trace in the paste. Often I have these kind of traces, where 90% is Guile internal stuff, that I do not understand. Then I can see somewhere after `(min-length)` I get an error. I am not calling min-length myself, so it must be some internal stuff
<Zelphir>or SRFI-43 stuff. I have tried "print debugging", but the error seems to happen inside the form of `vector-map`. Anything before I can print, but as soon as vector-map is called the error comes and I don't know what I did wrong. Somewhere internally some call of `cdr` seems to get an empty list and I don't know what is causing it.
<lampilelo>Zelphir: your vector-map call has only 1 argument, you put the vector outside the call, what threw an error is a check if the minimal amount of arguments was passed
<Zelphir>Oh. This is a little embarrassing. Oops! Thank you! Definitely been up too late yesterday (today).
<Zelphir>So `min-length` is used on the list of arguments. Aha! I was already wondering, whether I have anything in the code, which requires there to be at least 1 element in a vector or so.
<lampilelo>Zelphir: actually... i think the fact that this error was thrown is a bug, the code for vector-map allows a single argument to be passed but it fails later on, min-length call doesn't check the amount of arguments, it checks what is the length of the shortest vector that was passed
<lampilelo>a syntax-error should be thrown instead
<Zelphir>I am looking at https://srfi.schemers.org/srfi-43/srfi-43.html#vector-map and the examples all have at least 2 arguments + the signature is: `(vector-map f vec1 vec2 ยทยทยท) -> vector`. I think it makes only the second vector and following ones optional. Am I misunderstanding it?
<lampilelo>you are correct
<lampilelo>this is a bug in guile's implementation
<avp>Hello Guilers. Guile documentation snarfer ('doc-snarf') does not work with GOOPS code (for example it fails to properly read procedures defined with 'define-method'). Did anyone try to fix it?
<roptat>civodul, do you have a solution for local-time?
<roptat>localtime*
<avp>Huh, it seems that the last update to 'doc-snarf' was in 2011.
<lampilelo>that must mean it's feature complete
<avp>Well that might be the case. But when I use GOOPS in my code, 'doc-snarf' fails to get documentation from it.
<lampilelo>should've ended that statement with a smiley face, i was joking
<avp>lampilelo: :-)
<civodul>roptat: no, sorry!
<civodul>did you try (setenv "TZ" "...") before calling localtime?
<civodul>in the end it's just a matter of settin TZ and calling tzset(3) i think
<roptat>civodul, setting TZ means even (tm:gmtoff (localtime (current-time))) doesn't work
<roptat>I think this is because setting TZ automatically gives a value to zone, which calls localtime in a new environment where only TZ is set
<roptat>I also tried (setenv "TZ" "Asia/Tokyo") (tzset) (unsetenv "TZ") (tm:gmtoff (localtime (current-time))), but that gives me the offset of my own timezone, not Tokyo's
<ArneBab>I tried to write a Zen for Scheme, in the spirit of the Zen of Python, but a different form (because in Scheme it is more explicit that there are exceptions to rules and differences in opinion). I would love to hear your opinions on it: https://www.draketo.de/software/zen-for-scheme
<civodul>roptat: hmm, something must be buggy
<civodul>ok, looks like you had reached that conclusion much earlier :-)
<roptat>civodul, should I send a bug report?
<roptat>I think I see where it's not behaving correctly, but I don't really know how to fix it properly