開発環境
- 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 1(The way of the program)のExercises 1-1、2.を取り組んでみる。
Exercises 1-1、2.
コード(Emacs)
#!/usr/bin/env perl6 # -*- coding: utf-8 -*- say 42 * 60 + 42; say 10 / 1.61; say (10 / 1.61) / (42 * 60 + 42); say (10 / 1.61) / (42 + 42 / 60); say (10 / 1.61) / ((42 + 42 / 60) / 60);
入出力結果(Terminal, REPL)
$ perl6
You may want to `zef install Readline` or `zef install Linenoise` or use rlwrap for a line editor
To exit type 'exit' or '^D'
> 'a'
a
> 'a
*
* b
* '
a
b
> a'
===SORRY!=== Error while compiling:
Two terms in a row
------> a⏏'
expecting any of:
infix
infix stopper
statement end
statement modifier
statement modifier loop
> -2
-2
> +2
2
> +-2
-2
> -+2
-2
> 2++2
===SORRY!=== Error while compiling:
Two terms in a row
------> 2++⏏2
expecting any of:
infix
infix stopper
statement end
statement modifier
statement modifier loop
> 2--2
===SORRY!=== Error while compiling:
Two terms in a row
------> 2--⏏2
expecting any of:
infix
infix stopper
statement end
statement modifier
statement modifier loop
> 02
Potential difficulties:
Leading 0 does not indicate octal in Perl 6. Please use 0o2 if you mean that.
------> 02⏏<EOL>
2
> 0o2
2
> 0x2
2
> 0o10
8
> 0x10
16
> 0b10
2
> 2 2;
===SORRY!=== Error while compiling:
Two terms in a row
------> 2⏏ 2;
expecting any of:
infix
infix stopper
statement end
statement modifier
statement modifier loop
> 2; 2;
WARNINGS for <unknown file>:
Useless use of constant integer 2 in sink context (line 1)
2
> $ ./sample1.pl
2562
6.211180
0.0024243
0.145461
8p.727654
p$
0 コメント:
コメントを投稿