Drkcore

01 12 2009 Haskell Tweet

foldrでfilter

RWHのp.99

右から畳み込むはずなのに、、、不思議な感じがする。

myfilter p xs = foldr step [] xs
                where step x ys | p x = x:ys
                                | otherwise = ys

myfilter odd [1,2,3,4,5,6]
[1,3,5]

結局これは

(1:(3:(5:[])))

を評価してんのか。

ProductName Real World Haskell―実戦で学ぶ関数型言語プログラミング
Bryan O'Sullivan
オライリージャパン / 3990円 ( 2009-10-26 )


About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021