2010-06-30

superdot


Prelude Control.Applicative> let superdot =
(((<*>).(((<*>).).(((.).).).(.)))<*>const const)
Prelude ...> :t superdot
superdot ::
(b -> b -> c) -> (b1 -> b) -> b1 -> b1 -> c
Prelude ...> superdot compare snd (0, 1) (0, 0)
GT


Hi, it is NISHIO Hirokazu. I just needed "dot" operator for 2-args function.


Prelude ...> let superdot = \f g x y -> f (g x) (g y)
Prelude ...> superdot compare snd (0, 1) (1, 0)
GT


Why such a function isn't in Prelude?

2010-06-22

Haskell Quiz

This entry was moved to NISHIO Hirokazu's blog

2010-06-09

Haskell's random

Hi, it is NISHIO Hirokazu, Haskell newbie. Today I post a small code. It's not a bug. It's a feature of Haskell.


$ ghci
GHCi, version 6.8.3
Prelude> import Random
Prelude Random> let g = mkStdGen 1
Prelude Random> (fst (random g)) + 0
-604496784
Prelude Random> (fst (random g)) / 1
0.35925462466181596
Prelude Random> (fst (random g)) * 1
-604496784
Prelude Random> (fst (random g)) * 1.0
0.35925462466181596


Yes, it is a feature. Haskell's random changes its behavior by what type inferred. See The Haskell 98 Library Report: Random Numbers.

2010-06-07

2010-06-06

What The Fuck --- Twitter Trending from Japan('BEAT CRUSADERSが' and 'のTwitter廃人度は')

Hi, this is takano32.

Today's Twitter Trending in Worldwide is such as picture.



Many people are saying "What The Fuck? 'BEAT CRUSADERSが' and 'のTwitter廃人度は'".

There two words are Trendings from Japan.

'BEAT CRUSADERS' is rock band and they are active in Japan.
Today, BEAT CRUSADERS is publishing their breakup at official Web site.
And many Japanese shout "BEAT CRUSADERSが解散!?" in Twitter.
This means "Is it really breakup of BEAT CRUSADERS!?".

'Twitter廃人度' means how junky for Twitter.
A Web service telling fortune is a one of the most hot twitter service in Japan.
Today's trending fotune-telling Web service is Twitter廃人度チェッカー --- Check how are you junky for Twitter.
Many Japanese are check themselves and tweet their results in Twitter and make Twitter Trending 'のTwitter廃人度は'.

Many Japanese are affected by trend easily and a number of Japanese Twitter user is increasing.
So a number of trending words in Japanese may increase in the future.

Thank you.

2010-05-31

2010-05-27

FIX: ImportError: cannot import name ImmutableList

Hi, it is NISHIO Hirokazu. I'm moving my Django app into Google App Engine with Django-nonrel. I encountered the error and it took a lot of time from me. Google search didn't know anything about the problem.

The version of Django in Google App Engine is 1.0. Thus that of Django-nonrel(djangoappengine) is 1.2. It is the root of the problem.

Of cource, some code to avoid such a versioning problem was wrote in Django-nonrel. See djangoappengine/main/main.py


parent_dir = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
f parent_dir not in sys.path:
sys.path.insert(0, parent_dir)

# Remove the standard version of Django
if 'django' in sys.modules and sys.modules['django'].VERSION < (1, 2):
for k in [k for k in sys.modules
if k.startswith('django\.') or k == 'django']:
del sys.modules[k]


If sys.path doesn't have the path to Django in Django-nonrel, it add the path. If already old Django was imported, it remove that. But unfortunately, in my case, sys.path has the path, and the path to Django in Google App Engine preceded, but it's not imported yet.

It's mystery. I can't tell why it happened. But it actually happened.

I wrote a workaround for the problem. It bring the path to correct Django always on top.


parent_dir = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
if parent_dir in sys.path:
sys.path.remove(parent_dir)
sys.path.insert(0, parent_dir)