IRC channel logs

2020-12-26.log

back to list of logs

<fnstudio>hi, i need a 2d matrix, which i understand i can implement using an array; there are a couple of things, however, eg filtering, that don't seem to be provided
<fnstudio>am i missing anything? is there any addition to the core set of array-related procedures in any SRFI?
<fnstudio>or maybe everything i need is there (https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Array-Procedures.html) already, it's just me not knowing how to use it
<RhodiumToad>what kind of filtering?
<fnstudio>RhodiumToad: the kind of operation you'd do with a filter-map, i think - but i feel i need to think this through more carefully
<fnstudio>i mean, a filter-map, if it were a list
<daviid>fnstudio: docs-1.8 ? are you not using a more recent guile version?
<fnstudio>daviid: yes, i must be on a very recent one, if not the most recent - well spotted, 1.8 must be the result of a web search
<fnstudio>daviid: i'll double-check on a recent version
<fnstudio>thanks
<RhodiumToad>how would a filter-map make sense with a rectangular array?
<fnstudio>RhodiumToad: not sure, something that returns a list would work in my case i think - however if i use array->list i then miss the indexes
<fnstudio>array->list forgets the info about the x, y where my values come from
<RhodiumToad>you want to iterate over the array while knowing the indices, but the result would be a list rather than an array itself?
<RhodiumToad>(if you want to delete elements from the result, the result won't be an array because in general it would not be rectangular, no?)
<fnstudio>RhodiumToad: correct re iterating knowing the indices and then getting a list
<justin_smith>in clojure I would use map-indexed, passes two values two the function mapped over, an index and the item at that index
<justin_smith>if that doesn't exist in guile I don't think it would be a hard function two write
<justin_smith>*two values to the function ...
<daviid>fnstudio: what are the matrix content type? (if homogeneous)
<daviid>*matrices
<fnstudio>daviid: ideally a list but an integer could also do
<fnstudio>justin_smith: thanks, that's true; i thought of asking to make sure there wasn't anything else i was missing (eg thinking that i might be misusing the concept of array in the first place)
<ruffni>how can i define-method to have the first argument an object of my pre-defined class "point" and take a second argument (chickadee's vec2 type) ? when i (define-method (angle-to (p point) vector)) i get a "No applicable method for (...)" error
<ruffni>btw chickadee seems amazing and exactly what i was looking for!
<daviid>ruffni: great! wrt the error, if you paste (debian, gnome or any none tracking, no javascript, tor compliant ...) the class definition, the method definition, and a call together with the full error message ... then we can (maybe) help
<ruffni> https://dpaste.org/ZLRL
<ruffni>and here in "Plain Code" format: https://dpaste.org/DExj
<daviid>ruffni: this is not a tor friendly site, but I'll have to let others help, hopefully someone will shime in, I am too busy at the moment ...
<tohoyn>ruffni: should you have (define-method (angle-to (p point) (vector vec2)) ?
<tohoyn>ruffni: is vec2 a goops class?
<jadzi>Hi, Guilers! I'm playing with (sdl2) and need some help with a problem. Debian 10 machine, same on guile v2 v2.2 v3. Tried both with (sdl2) version 0.5.0 and master branch. (sdl-version) is (2 0 12). I've illustrated the code with an exception backtrace here: https://gist.github.com/denyadzi/29783ddae315e0bd5b2bb31fd135bddb. I want show a piece of image on the window with this code
***apteryx is now known as Guest72305
***apteryx_ is now known as apteryx
<ruffni>daviid: not sure what you mean by "tor friendly", but i created that snipped with torbrowser (and am able to see it with "safest" torbrowser settings)...
<ruffni>tohoyn: vec2 is defined in chickadee, i think it's a (define-record-type), not a goops class.
<leoprikler>ruffni: should this be the angle between two points?
<leoprikler>Either way, I'd suggest you do a match-lambda*
<leoprikler>(((? point? p) (? vec2? vector)) <your code here>)
<leoprikler>the benefit of match-lambda is, that it also works outside of goops classes
<leoprikler>that said, your method *should* accept a point + anything, are you sure, that you're passing a point?
<chrislck>Happy SRFI-111 day!!!
<ruffni>yes, this is supposed to be the angle between to points, but one is a point as defined by me in a GOOPS class and the other is just a 2-dimensional vector. i'll give match-lambda* a try!
<ruffni>so GOOPS define-method only works if all the arguments are instances of GOOPS classes?
<leoprikler>ruffni: nah, you can have inputs of arbitrary type, but idk about type matching record types
<ruffni>i don't care too much about type matching (as long as the first argument is a point), so define-method would work for me.. but how do i define a method without type-checking the second argument?
<leoprikler>again, your syntax *should* be correct, it's probably failing to match your point or you have wrong number of arguments
<leoprikler>debugging define-method is sadly everything but simple
<leoprikler>you could try (define-method (method . args) (error "wtf?" (map class-of args))) as a catch-all
<ruffni>thanks!
<spk121>wingo: I've got a patch to the ports test I'd like to push. https://github.com/spk121/guile/commit/9c886644d05d0d7a052555b7e0bbc067c7e140c7