開発環境
- macOS Sierra - Apple (OS)
- Emacs (Text Editor)
- Perl 6 (プログラミング言語)
- Rakudo(コンパイラ、実装)
Think Perl 6: How to Think Like a Computer Scientist (Laurent Rosenfeld(著)、Allen B. Downey(著)、Oreilly & Associates Inc)のPart 1(Starting with the basics)、Chapter 9(Arrays and Lists)の Exercise: Mapping and Filtering the Elements of a List.を取り組んでみる。
Exercise: Mapping and Filtering the Elements of a List.
コード(Emacs)
#!/usr/bin/env perl6 # -*- coding: utf-8 -*- my @input = 1..10; say map {$_ * $_}, @input; say grep { my $sqrt = sqrt $_; $sqrt * $sqrt == $_; }, @input;
入出力結果(Terminal, REPL)
$ ./sample_square.pl (1 4 9 16 25 36 49 64 81 100) (1 4 9) $
0 コメント:
コメントを投稿