diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-06-16 13:53:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-16 13:53:02 +0100 |
| commit | 05d23301d7fa46079a175295aaf3ddbdba91d7ad (patch) | |
| tree | 56945c9a9418c63c30d09c159ba6d5d2128ff1be | |
| parent | 509b1323f0a7ee460e66b31d354b1d769a557f0b (diff) | |
| parent | bcdef5ae4f5ddf92285c1c93d0012d530ee8c352 (diff) | |
| download | perlweeklychallenge-club-05d23301d7fa46079a175295aaf3ddbdba91d7ad.tar.gz perlweeklychallenge-club-05d23301d7fa46079a175295aaf3ddbdba91d7ad.tar.bz2 perlweeklychallenge-club-05d23301d7fa46079a175295aaf3ddbdba91d7ad.zip | |
Merge pull request #262 from fjwhittle/master
fjwhittle ch-3.p6 fixes after testing.
| -rw-r--r-- | challenge-012/fjwhittle/perl6/ch-3.p6 | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/challenge-012/fjwhittle/perl6/ch-3.p6 b/challenge-012/fjwhittle/perl6/ch-3.p6 index d0b605078f..e56616fdb2 100644 --- a/challenge-012/fjwhittle/perl6/ch-3.p6 +++ b/challenge-012/fjwhittle/perl6/ch-3.p6 @@ -25,10 +25,16 @@ my $result = await(Cro::HTTP::Client.get($uri).then({await .result.body})); # This bit is tested. $result<error> and die "API responded with error ‘$result<error>’"; -my $synonyms = $result<results><result><synonyms>; +try { + my $synonyms = $result<result> ~~ Array + ?? $result<result>»<synonyms> + !! [$result<result><synonyms>]; -say "Synonyms for ‘$word’ using the Synonyms API from STANDS4:"; -say $synonyms; + $synonyms .= grep(* ~~ Str) or fail; + + say "Synonyms for ‘$word’ using the Synonyms API from STANDS4:"; + say $synonyms».split(', ').flat.unique.join(', '); +} or say "No Synonyms found for ‘$word’"; CATCH { when X::Cro::HTTP::Error { |
