開発環境
- 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 5(Fruitful Subroutines)、Boolean Functions の Exercises.を取り組んでみる。
Exercises.
コード(Emacs)
#!/usr/bin/env perl6
# -*- coding: utf-8 -*-
sub is-between($x, $y, $z) {
$x <= $y <= $z;
}
for 1..2 -> $x {
for 1..2 -> $y {
for 1..2 -> $z {
say "$x, $y, $z: ", is-between $x, $y, $z;
}
}
}
入出力結果(Terminal, REPL)
$ ./sample_between.pl 1, 1, 1: True 1, 1, 2: True 1, 2, 1: False 1, 2, 2: True 2, 1, 1: False 2, 1, 2: False 2, 2, 1: False 2, 2, 2: True $
0 コメント:
コメントを投稿