任意次元の格子点を(大量のメモリを使うことなく)生成するコードを出来るだけ汎用的に書いてみるテスト。 Python ならかなり簡単に書ける。generator(コルーチン)万歳。 def mesh(*points): if len(points) == 1: for x in points[0]: yield [x] else: for point in mesh(*points[:-1]): for x in points[-1]: yield point + [x] if __name__ == '__main__': for point in mesh(range(10), range(10), range(10)): print point Perl ならこんな感じ?めんどい。 sub mesh_iterator { my @coords = @_; my @indices = m

