2017年5月18日木曜日

開発環境

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 10(Hashes)の Exercise: A Hash Is a Mapping.を取り組んでみる。

Exercise: A Hash Is a Mapping.

コード(Emacs)

#!/usr/bin/env perl6
# -*- coding: utf-8 -*-

my %employees = (Liz => 3000,
                 Bob => 2500,
                 Jack => 2000,
                 Betty => 1800);

for %employees {
    say $_;
}

for %employees.values {
    say $_;
}

for %employees.keys {
    say $_;
}

入出力結果(Terminal, REPL)

$ ./sample01.pl
Liz => 3000
Bob => 2500
Betty => 1800
Jack => 2000
3000
2500
1800
2000
Liz
Bob
Betty
Jack
$

0 コメント:

コメントを投稿