?

Log in

No account? Create an account
Haskell wearing me down - Greg [entries|archive|friends|userinfo]
Greg

[ website | gregstoll.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| * Homepage * Mobile apps (Windows Phone, Win8, Android, webOS) * Pictures * LJBackup * Same-sex marriage map * iTunesAnalysis * Where's lunch? ]

Haskell wearing me down [Aug. 15th, 2007|10:57 am]
Greg
[Tags|, , ]
[Current Mood |worriedworried]

but first, math!

From last time - the answer is that they're not symmetric. If a=10, b=11, c=20, then C enters A's stall at time 10 and you get to enter B's stall at time 11. However, if a=20, b=11, c=10, then C enters B's stall at time 11 and you have to hold it until time 20. More formally, the time you have to wait is

min(min(a,b) + c, max(a,b))

Using the formulas min(a,b) = (a+b-|a-b|)/2 and max(a,b) = (a+b+|a-b|)/2, this expression simplifies down to (a+b+c-|c-|a-b||)/2, which is clearly not symmetric in a and c. I'd be interested to see how this formula works for more people and stalls - it seems to blow up pretty quickly, although it would be easy to write a program to calculate it. I have a gut feeling that you want the fastest people earlier in the line (ideally if there are n stalls the n-1 slowest people will be all in their stalls when you get to go in, so you don't have to wait for them) but proving that seems rather tricky.

When will LJ get inline LaTeX?? :-)

Good article about risk management and terrorism (via schneier)

I'm making good progress rewriting the Pretty Pictures picture generator in Haskell - it spits out valid PPM images that look correct for simple cases, but it needs more testing. (and I need to see if browsers support PPM natively or if I have to convert to PNG which would be a pain) I'm not enjoying it a whole lot, though. The idea of learning Haskell was to expand my mind and change the way I programmed, and I guess it has done that some, but I always feel handcuffed when I sit down and try to do seemingly easy things, like write out a raw PNG file. (got about halfway there and said forget it)

To antidote this (yes, it's a verb!) I think my next project will be less challenging technically and more interesting, like involving lots of neat data (census? past wars?) and some sort of neat visualization. (R?) We'll see.
LinkReply

Comments:
[User Picture]From: djedi
2007-08-15 03:46 pm (UTC)
Have you considered some sort of game? Those are fun and challenging, or as challenging as you want to make them!

(Reply) (Thread)
From: (Anonymous)
2007-08-15 05:04 pm (UTC)
Mmm, games...
(Reply) (Parent) (Thread)
[User Picture]From: kernelm
2007-08-15 03:48 pm (UTC)
I doubt most browsers would support PPM. I haven't worked with Haskell in a long time, but I can definitely see any sort of I/O beyond simple text being difficult to work with. I should really play with Haskell again. I miss functional programming.
(Reply) (Thread)