clacke[m] has quit [Remote host closed the connection]
peddie1 has quit [Remote host closed the connection]
Blackbeard has quit [Remote host closed the connection]
joebobjoe has quit [Client Quit]
clacke[m] has joined #racket
peddie has joined #racket
keep_learning has joined #racket
pie___ has joined #racket
pie__ has quit [Ping timeout: 264 seconds]
<greghendershott>
hjek: The markdown renderer for scribble exists mainly because there was a time when the new package system didn't render docs automatically like the old PLaneT system.
<greghendershott>
I submitted a PR to add export-as-markdown so you could at least put something in your e.g. GitHub README.md.
<hjek>
nice. that would be neat
<greghendershott>
It was an interim thing. It sucked, but not as badly as having no docs online. :)
<greghendershott>
I think these days it's moot.
<hjek>
oh, i see you're the creator of the racket markdown package!
<Yaargh>
trying to move a dot left or right via key events
<Yaargh>
it runs fine but fails when I press a key: vector-ref: expects a vector as 1st argument, given (void)
ZombieChicken has joined #racket
<Yaargh>
i cant see how the value is void
<Yaargh>
appreciate any help
<lexi-lambda>
vector-set! returns #<void>, and the on-key handler is supposed to return a new state.
<Yaargh>
also i have zero programming experience
<Yaargh>
why is it void?
<lexi-lambda>
vector-set! performs an imperative update that modifies an existing vector. You might want to use vector-set instead of vector-set! to produce a new vector instead of modifying the old one.
<Yaargh>
ahhh
<Yaargh>
but still (vector-set! X/Y 0 (sub1 (vector-ref X/Y 0)))
<Yaargh>
i dont see why this isnt just decrementing the value instead of returning void
<jcowan>
It just happens to be defined that way. (It actually does return a value, but that value could be anything depending on the implementation.)
<jcowan>
This is true of most update operations in Scheme.
<lexi-lambda>
rudybot: init racket
<rudybot>
lexi-lambda: your sandbox is ready
<lexi-lambda>
rudybot: (define v (vector 1 2))
<rudybot>
lexi-lambda: Done.
<lexi-lambda>
rudybot: (vector-set! v 1 3)
<rudybot>
lexi-lambda: Done.
<lexi-lambda>
rudybot: v
<rudybot>
lexi-lambda: ; Value: '#(1 3)
<aeth>
On the other hand, basically every Scheme takes undefined literally and returns something like #<undefined> (or in Racket's case, #<void>)
<lexi-lambda>
Apparently Racket doesn’t provide vector-set, only vector-set!.
<aeth>
While in Scheme everything is an expression, not everything is meaningfully useful as an expression, which is unfortunate.
<Yaargh>
lexi-lambda: was just looking in the reference for vector-set
<lexi-lambda>
rudybot: eval (define (vector-set vec n v) (define vec* (vector-copy vec)) (vector-set! vec* n v) vec*)
<rudybot>
lexi-lambda: Done.
<lexi-lambda>
rudybot: eval (vector-set v 1 4)
<rudybot>
lexi-lambda: ; Value: '#(1 4)
<lexi-lambda>
rudybot: eval v
<rudybot>
lexi-lambda: ; Value: '#(1 3)
<Yaargh>
ok i am more confused now
<Yaargh>
can i simply index the vector an mutate the value?
<lexi-lambda>
big-bang is designed to be used in a pure way, without mutating the state.
<Yaargh>
ah i see
<lexi-lambda>
The idea is that each on-tick, on-key, etc. handler is supposed to return a new state.
<Yaargh>
ok i shall change to a more functional way
<lexi-lambda>
Yaargh: If you wanted, you could probably just put (define (vector-set vec n v) (define vec* (vector-copy vec)) (vector-set! vec* n v) vec*) at the top of your program and change your vector-set! calls to vector-set, and things would likely work.
<Yaargh>
in this case it is trivial but wouldnt a lot of vector copying be less performant?
<lexi-lambda>
Yes. My guess is that is why Racket does not provide vector-set.
<Yaargh>
alright thanks
<lexi-lambda>
I have a pvector package that implements persistent vectors, which have an efficient functional set operation, but the package is maybe not ideal at the moment.
<lexi-lambda>
With vectors of two elements the cost should be irrelevant, though.
<Yaargh>
yeah
<Yaargh>
i am on the first chapter of how to design programs
<Yaargh>
am punching above my weight here
<Yaargh>
i will just continue the book :)
<lexi-lambda>
I think if you are using BSL, vectors are not even available. :)
<Yaargh>
nope
<lexi-lambda>
I think BSL has a posn struct that might work better for you here.
<Yaargh>
oh cool
<Yaargh>
thanks
<lexi-lambda>
Maybe posn is only available in ISL, though, I’m not sure.
<Yaargh>
it was a case of "you don't know what you don't know"
<Yaargh>
ha thats actually the chapter im reading but i hadnt got that far down yet
Yaargh has quit [Quit: Going offline, see ya! (www.adiirc.com)]
sz0 has quit [Quit: Connection closed for inactivity]
badkins has joined #racket
mahmudov has quit [Ping timeout: 250 seconds]
<jcowan>
It's odd that BSL has no vectors when it has everything else your basic Scheme has, plus structures.
<zenspider>
why is that odd to you?
ZombieChicken has quit [Remote host closed the connection]
ZombieChicken has joined #racket
<jcowan>
What is so special about vectors that they should be left out? Lists have more conceptual issues than vectors, not to mention worse terminology.
keep_learning has joined #racket
dbmikus_ has quit [Ping timeout: 240 seconds]
keep_learning has quit [Remote host closed the connection]