LoginSignup
1
2

More than 3 years have passed since last update.

Pythonの再帰ラムダでピラミッドを建造した

Last updated at Posted at 2018-05-30

「不動点コンビネータ」とは

Pythonのlambda式で再帰をやるには「不動点コンビネータ」を使うと良いと聞き、言葉の響きがかっこいいので実装した。不動点???

print(lambda f:f("#\n",f))(lambda s,f:s if len(s)>99 else " "*int(50-len(s)/2)+s+f("#"*4+s,f))

様子

スクリーンショット 2018-06-12 9.41.01.png

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2