Concurrent Clean
クロージャからの連想 <- [id:lethevert:20050813:p2]
searchChar :: Char String searchChar c str = searchChar` c 0 (size str) str where searchChar` c pos len str | pos >= len = -1 | str.[pos] == c = pos | otherwise = searchChar` c (pos+1) len str
上のコードは、下のように書き直せる。
searchChar :: Char String searchChar c str = searchChar` 0 where len = (size str) searchChar` pos | pos >= len = -1 | str.[pos] == c = pos | otherwise = searchChar` (pos+1)