Comment detail

トランプの和と積のパズル (Nested Flatten)

This comment is reply for 1613 匿名: 最終バージョンです。 相変わらず効...(トランプの和と積のパズル). Go to thread root.

感動したので Squeak Smalltalk に直訳っぽくしてみました。
1
2
3
4
5
6
7
8
9
| n o a |
n := 13.
o := (1 to: n) inject: #() into: [:r :i | r, ((i to: n) collect: [:j | {i. j. i*j. i+j}])].
a := o select: [:t | (o count: [:u | u third = t third]) > 1].
o := o select: [:t | (o count: [:u | u fourth = t fourth]) > 1].
o := o select: [:t | a includesAllOf: (o select: [:u | u fourth = t fourth])].
o := o select: [:t | (o count: [:u | u third = t third]) = 1].
o := o select: [:t | (o count: [:u | u fourth = t fourth]) = 1].
^o collect: [:t | t first: 2]
最後の方をこんな感じにするのはありですか?(笑

o := o  select: [:t | (o count: [:u | u fourth = t fourth]) = 1].
    ^o collect: [:t | t first: 2]

なんだか
[:t
が顔に見えてくる…
[:u | 

顔だ…
ホントだ。w

インデントは自由ですので、#1627 も可能です。

Index

Feed

Other

Link

Pathtraq

loading...