2005-11-01から1ヶ月間の記事一覧

map (\xs -> zip xs [1..]) list

とりあえず入力。 Prelude List> map (\xs -> zip xs [1..]) list :1:26: Not in scope: `list' listなんて作ってないもんな・・・ Prelude List> map (\xs -> zip xs [1..]) [1,2] :1:27: No instance for (Num [a]) arising from the literal `1' at :1:27…

\x -> x + 1

Tour of the Haskell Syntax http://www.cs.uu.nl/~afie/haskell/tourofsyntax.html の Anonymous function can be made using lambda expressions. For example \x -> x + 1is a function with one parameter which it will add one to. Lambda expressions…

Tour of the Haskell Syntax

http://www.cs.uu.nl/~afie/haskell/tourofsyntax.html#Lambda%20expressions をやってみる。

関数合成 やりのこしてること

f(x)=x+1 g(x,y)=x*y を合成してh(x,y)=x*y+1をつくろう!というココロミは成功したんだけど・・・ 次の目標として、 f(x)=x+1 g(x,y)=x/y から、h(x,y)=x/y+1をつくろう、というのは、f . (g x) yでできる。 で・・・h'(x,y)=x/(y+1)ってのは関数合成でどう…

関数合成

func1::Int -> Int func1 x = x + 1 func2::Int -> Int -> Int func2 x y = x * y func3::Int -> Int -> Int func3 x y = (func1 . func2 x) y func3 = x * y + 1にしようとしたのだが、思いつくまでにだいぶ時間がかかってしまった。 (func1 . func2) x y …