2019年9月16、17日、日本最大のPythonの祭典である「PyCon JP 2019」が開催されました。「Python New Era」をキャッチコピーに、日本だけでなく世界各地からPythonエンジニアたちが一堂に会し、さまざまな知見を共有します。プレゼンテーション「Pythonで始めてみよう関数型プログラミング」に登壇したのは、株式会社SQUEEZEの寺嶋哲氏。講演資料はこちら 不変/永続データ構造を提供するパッケージ寺嶋哲氏:続いて、不変/永続データ構造についてです。 listを操作する関数の問題点について、例題で見ていきましょう。add_mangoは果物名の文字列のlistをとって、mangoをそのlistに足して返します。change_from_apple_to_bananaは、同じようにlistをとってappleを探して、bananaに入れ替えて返します。 その下
I have never considered Python to be heavily influenced by functional languages, no matter what people say or think. I was much more familiar with imperative languages such as C and Algol 68 and although I had made functions first-class objects, I didn't view Python as a functional programming language. However, earlier on, it was clear that users wanted to do much more with lists and functions. A
Many functional programming articles teach abstract functional techniques. That is, composition, pipelining, higher order functions. This one is different. It shows examples of imperative, unfunctional code that people write every day and translates these examples to a functional style. The first section of the article takes short, data transforming loops and translates them into functional maps a
In this series we take an in-depth look at transducers. Transducers - a portmanteau of "transform reducers" - are a new functional programming concept introduced into the Clojure programming language. Although transducers are actually pretty straightforward in retrospect, wrapping your brain around them, especially if you're not already a competent Clojureist, can be challenging. In this series, w
What are exceptions? Judging by their name it is an entity representing some exceptional situation that happens inside your program. You might be wondering how do exceptions are an anti-pattern and how does this relate to typing at all? Well, let’s find out! Problems with exceptions First, we have to prove that exceptions have drawbacks. Well, it is usually hard to find “issues” in things you use
はじめに こちらはモナド・圏論を理解するための勉強メモ。 モナドや圏論をプログラミングの側から勉強しようとすると、Haskellのコードがよくでてくる。 しかし自分は(いずれ触りたいけど)Haskellに慣れていないのでよくわからない。 なのでそれなりに慣れていてかつ動作確認しやすいPythonで実装しながら攻めてみる。 Maybeモナド 計算結果が不定の値を扱うための抽象概念 確定している値(a)は Just a と表す 値が存在しない場合は Nothing と表す 計算過程で例外が発生しうる処理を、例外処理の考慮なしに実装したい場合に使える 参考 http://labs.timedia.co.jp/2011/05/monad-in-python.html https://qiita.com/south37/items/06cfa95aa9c8f2ecb2e9 実装 モナドクラス(仮)
Pyrsistent is a number of persistent collections (by some referred to as functional data structures). Persistent in the sense that they are immutable. All methods on a data structure that would normally mutate it instead return a new copy of the structure containing the requested updates. The original structure is left untouched. This will simplify the reasoning about what a program does since no
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く