2017年2月19日日曜日

開発環境

Think Perl 6: How to Think Like a Computer Scientist (Laurent Rosenfeld(著)、Allen B. Downey(著)、Oreilly & Associates Inc)のChapter 1(The way of the program)のExercises 1-1、2.を取り組んでみる。

Exercises 1-1、2.

コード(Emacs)

入出力結果(Terminal)

$ 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'
> 'hello
* '
hello

> "hello
* "
hello

> hello"
===SORRY!=== Error while compiling:
Two terms in a row
------> hello⏏"
    expecting any of:
        infix
        infix stopper
        statement end
        statement modifier
        statement modifier loop
> hello
===SORRY!=== Error while compiling:
Undeclared routine:
    hello used at line 1. Did you mean 'shell'?

> 2+2
4
> 2+-2
0
> 2-2
0
> 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
> 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
> 2,2;
(2 2)
> 42 * 60 + 42;
2562
> 10 * 1.61;
16.1
> (10 * 1.61) / (42 + 42 / 60)
0.377049
> (42 + 42 / 60) / (10 * 1.61);
2.652174
> (42 * 60 + 42) / (10 * 1.61);
159.130435
> (10 * 1.61) / ((42 + 42 / 60) / 60)
22.622951
> $ 

0 コメント:

コメントを投稿