IRC channel logs

2014-05-28.log

back to list of logs

<davexunit>hey guilers.
<davexunit>anyone familiar with vector math? I have a 2D vector type, and now I'm adding a 3D vector type. Ideally, I'd like to use the same procedures to operate on both types of vectors and DTRT.
<davexunit>and I have to handle cases like adding a 2d vector to a 3d vector.
<davexunit>should [1 1] + [1 1 1] = [2 2 1] or throw an error?
<davexunit>it would be convenient to treat 2d vectors as 3d vectors with a 0 z component, but I don't think it's necessarily the right way to do things.
<davexunit>the z component is undefined, not zero.
<davexunit>I guess throwing an error would be best, for mathematical correctness.
***fangism is now known as fangism-ctrl-Z
<nalaginrut>morning guilers~
***sethalve_ is now known as sethalves
<b4283>are the forms (define (a x) x) and (define b (lambda (x) x)) equivalent ?
<b4283>nvm, i've found the answer R6RS:11.2.1 Variable definitions
<b4283>i wonder why The Little Schemer prefer the latter form
<nalaginrut>b4283: yes they are the same
<nalaginrut>but I like the latter too
<nalaginrut>I picked the former now, because wingo told me do so
<nalaginrut>b4283: you can use ,exp in REPL to confirm
<b4283>nalaginrut: the lambda is just redundant, but if the scheme language want to trim down the fats, the latter form would probably go
<b4283>nalaginrut: cool, thx
<nalaginrut>I love to see 'lambda' each time
<nalaginrut>I think many people has the same habit ;-P
<b4283>but i think (define (a x) x) has the disadvantage to make people misunderstand that there's a function namespace
***linas__ is now known as linas
<bhattigurjot>I am getting this error:
<bhattigurjot>fatal error: libguile.h: No such file or directory
<bhattigurjot>compilation terminated.
<bhattigurjot>I have installed guile 2.0.11 from deb package
<jmd>bhattigurjot: And what are you trying to do?
<bhattigurjot>compiling a software that uses guile
<jmd>Then you need the -dev package.
<bhattigurjot>jmd: but this -dev package must be 2.0.11 compatible.. right?
<bhattigurjot>btw I downloaded this from https://packages.debian.org/unstable/lisp/guile-2.0
<jmd>apt-get install guile-dev
<jmd>(or similar)
<bhattigurjot> https://packages.debian.org/sid/guile-2.0-dev
<bhattigurjot>is this it?
<jmd>I expect so.
<bhattigurjot>ok
<jmd>Obviously if you are using unstable, you are expected to know what you are doing.
<bhattigurjot>ok
<lloda>davexunit: [a b] + [c d e], I think it should be an error.
<lloda>Not because of math correctness, I think that's arbitrary. It may be correct to pad with 0 if you define it so. J pads with 0. In an OpenGL context it makes sense to have [a b] = [a b 0] (or [a b] = [a b 0 1] I suppose).
<lloda>But because it's easier to be strict and then relax, than the other way around, if you change your mind.
<civodul>Hello Guilers!
<lucasaiu>:-)
<saul>b4283, defining with lambda is useful when creating generators or otherwise capturing state. For example, (define gen-counter (let ((count 0)) (lambda () (set! count (+ count 1)) count)))
<davexunit>lloda: I came to same conclusion that [a b] + [c d e] should be an error. now I have a new problem!
<civodul>howdy lucasaiu!
<civodul>how are you?
<lucasaiu>Fine, thanks :-)
<lloda>davexunit: which problem? btw the Guile routines (vector-map, array-map!, etc) accept mismatched sizes, so you'd need to wrap them (or not use them) if you don't want to
<lucasaiu>At work now
<lucasaiu>I have a nice idea for a GHM presentation
<lucasaiu>Un nouveau port d'epsilon, sur une machine très petite
<lucasaiu>Sorry :-)
<lucasaiu>Well, you understood
<lucasaiu>The title will be "ode to a childhood dream"
<davexunit>lloda: ah, sorry. I'm not representing vectors (math) as vectors (data structure)
<lucasaiu>An epsilon cross-compiler for the Commodore 64
<lucasaiu>It nearly works
<civodul>lucasaiu: sounds cool :-)
<civodul>you'll have to bring a Commodore 64, then
<davexunit>lloda: my new problem is that I want my vector procedures to support 2D and 3D vectors. I have a procedure for adding vectors, v+, and it accepts 0 or more vectors. By supporting multiple types of vectors, the case where 0 vectors are given is undefined.
<davexunit>adding 0 vectors should result in the null vector, but there's no way to determine the dimensionality of that vector.
<lloda>davexunit: You could support frame-matching :) then you could just return 0 there.
<davexunit>what is frame-matching?
<lloda>the frame is the shape of the array. For a 3D vector, that's [3]. For a 3D vector, that's [2]. For a scalar, that's [].
<lloda>(for a 3x3 matrix, it would be [3 3]).
<lloda>two operands are compatible if their frames 'match'
<lloda>which means that they have the same values in the same places, and you ignore the places without values.
<lloda>so [3] matches [3], [3 4], or [3 9 4].
<lloda>[] matches anything.
<davexunit>I'm not sure that will help solve my problem.
<dsmith-w`>Commodore 64!
<lloda>it means that you define (+ [a b c] d) as [(+ a d) (+ b d) (+ c d)]
***dsmith-w` is now known as dsmith-work
<dsmith-work>brings back memories
<lloda>your identity for 3D/2D + is now just 0
<davexunit>lloda: okay, that helps.
<davexunit>I still want 2D/3D vectors to be incompatible for addition and such.
<davexunit>but I will accept scalar values.
<lloda>my experience is that it's much harder to mix ranks by mistake, than it is to mix sizes.
<davexunit>another question: I currently have a 2d vector defined as a record type. should I just use the vector data structure?
<civodul>arrays, no?
<davexunit>yeah, an array might be better than a vector.
<davexunit>it is somewhat convenient to have a distinct data type for the vector, but maybe it's not worth it.
<civodul>i mean arrays are meant to be used to represent vectors and matrices of all kinds
<civodul>it's a fundamentally imperative data structure though
<davexunit>yeah, I made my vector type immutable, which is also useful.
<davexunit>gah, I just don't know what to do.
<lloda>what does fundamentally imperative mean? you can use arrays functionally
<lloda>the immutability bit is going to happen at some point because of the problem with modifying literals
<lloda>arrays are useful if you manipulate lots of vectors together, and you take advantage of the generality and the O(1) operations (different ranks, reshaping, transposing). If you manipulate 2/3D vectors individually, there's little difference with using a record.
<lloda>that said, having more people using Guile arrays would be good for Guile, I think
<civodul>lloda: one can use arrays functionally, but it's going to be terribly inefficient: you'd have to copy the whole array each time you modify a cell
<lloda>right, inefficient for large arrays
<davexunit>right now, I do 2d vector math by producing a new vector2 object for each operation like addition, scalar multiplication, cross product.
<davexunit>which is inefficient, but I think making my vector2 type mutable is asking for trouble.
<civodul>davexunit: vector2 means a 2-element vector, right?
<davexunit>yes
<lloda>those are very small objects, I doubt it's too inefficient, especially when all the components of the result are new
<davexunit>it has x and y fields.
<davexunit>lloda: cool.
<civodul>yes, it's okay
<davexunit>I'm sort-of emulating what I see in other game engines that provide vector2, vector3, and sometimes vector4 types.
<davexunit>most importantly, the OpenGL shading language provides these 3 types.
<b4283>saul: yeah, i know about closure
<davexunit>additionally, I have a 4x4 matrix type, which does use an array.
<davexunit>and operations on matrices return new matrices, which is more inefficient because it's 16 elements.
<stis>anybody: if you want to see a cool parser of python check out: https://gitorious.org/python-on-guile
<stis>at least that is my dream parser framewark, pretty function oriented
<stis>does everything in one pass, scanning parsing and tokenizing
<stis>and ouputs AST
<stis>I used it as a test case for the guile-log parser framework
***fangism-ctrl-Z is now known as fangism
<dsmith-work>sneek: botsnack
<sneek>:)
<dsmith-work>civodul: Weird. eth0 was disabled.
<dsmith-work>civodul: So ya, networking.
<dsmith-work>sneek: seen wingo
<sneek>wingo was here May 12 at 06:35 pm UTC, saying: brb.
<dsmith-work>sneek: seen civodul
<sneek>civodul was here May 12 at 02:37 pm UTC, saying: heheh.
<dsmith-work>Ok, back in the box..
<civodul>thanks, dsmith-work :-)
<civodul>stis: "get sage to run on Guile", oouch!
<civodul>stis: so it parses Python 2?
<stis>civodul: not yet, buut most of the spec is translated
<stis>remains to debug the tool a little
<stis>the sage thing is to have a cool goal. Probably impossible to reach it :-)
<stis>civodul ^^
<civodul>possibly :-)
<civodul>but the parser in that repo is surprisingly small
<civodul>i guess guile-log does a lot of the heavy lifting?
<stis>Yep, there is a heavy macro, setup-parser, that create a functional parser framework with arbruitrary variables that can flow with the parsing
<stis>I needed to mod the vanilla parser to introduce the identation stack
<stis>so everything is done in one pass, also the identation handling.
<stis>another nice feature is that the tokenizer is done very loose via memoization, this means that the parser is much faster than what you would believe
<stis>and of cause you can use backtracking, and all kanrenlike features for parsing such as the interleaving, storage of state and restorage of stete etc
<stis>but those features are a bit of overkill
<civodul>oh, sounds interesting
<cluck>it would be hilarious if guile managed to hijack python2's community and left python 3 eating dust
<stis>cluick: tail calls, continuations ...
<cluck>exactly =)