牌語備忘録 -pygo

あくまでもメモです。なるべくオフィシャルの情報を参照してください。

牌語備忘録 -pygo

2008-07-08から1日間の記事一覧

2.2.3 Sequences as Conventional Interfaces の Sequence OperationsをPythonでやってみた

SICPの2.2.3 Sequences as Conventional Interfaces(慣習的な作用する配列) の Sequence Operations(配列操作) あたりを Python でやってみた scheme ;2.2.3 Sequences as Conventional Interfaces ;Sequence Operations (define (filter predicate sequ…

Scheme と cons と Python と

早くもSICPの2章でわけわからんと思ってたら、なんかSequenceの扱いを勘違いしてただけだったかも(||゚Д゚) scheme の cons や append と python の appendとか なので確認してみる。 scheme gosh> (cons (list 1 2 3 4 5) (list 1 2 3 4 5)) ((1 2 3 4 5) 1 …

ダックタイピングをPythonでやってみた

以下WikipediaからダックタイピングのRubyでの単純な例を引用 Ruby def test(foo) puts foo.sound end class Duck def sound 'quack' end end class Cat def sound 'myaa' end end test(Duck.new) test(Cat.new) 結果 quack myaa で、これをPythonでやってみ…

三項演算子をPythonでやってみた

なんとなく知ってるような知らないような三項演算子を使ってPythonでやってみた 奇数か偶数か判定する関数 def odd_or_even(n): return "odd" if n % 2 else "even" print odd_or_even(1) #odd(奇数) print odd_or_even(100) #even(偶数) 結果 odd even …