Tuesday, June 22, 2010

Haskell Quiz

Hi, it is Dr. NISHIO Hirokazu. Today I made a quiz. See following code and answer the definitions of a, b, c and d.


main = do
print $ a + c == 0 -- True.
print $ a == c -- True. a == c == 0.
print $ c == 0 -- True. Of course.
print $ a + d == 1 -- True. d == 1.
print $ b + c == 1 -- True. b == 1.
print $ b + d == 0 -- True. What happened?!
print $ b == d -- True. ?!
print $ d == 0 -- True. ?!?!
-- hints to make answer unique (perhaps...)
print $ sum([a, b, c]) -- 1
print $ sum([a, b, d]) -- 1
print $ [a, b, c] !! a -- 0
print $ [a, b, c] !! b -- 1
print $ [a, b, c] !! c -- 0


I swear:

  • I didn't define (+)
  • I didn't define (!!)
  • I didn't define (==)
  • I didn't define sum
  • I didn't define print
  • I didn't define ($) -- @kmizu sent me a valid solution and he defined ($). I didn't.
  • I didn't use default -- @camlspotter said it may use defaulting, and I didn't know it. I agree with him that it would be easier if I used defaulting. But I didn't. I didn't use default defaulting (i.e. default ordering of Integer and Double) For more detail, see http://www.haskell.org/onlinereport/decls.html#sect4.3.4

All of them are original, came from the prelude module.

The answer will be published on the blog at least 1 week after.

Monday, June 7, 2010

PONG-like game played on iPad with tangible controller

Hi, it is NISHIO Hirokazu. Today I introduce my recent demo movie of Muroto system. Using MUROTO you can controll games on iPad with tangible figures. There are "Muroto device" under the figures. And "Muroto library" tells the type of figures you put on iPhone, the direction and position.

It's not jail-braked. See further information on http://www.nishiohirokazu.org/muroto/