diff options
| author | Francis Whittle <FJ.Whittle@gmail.com> | 2019-06-16 21:58:38 +1000 |
|---|---|---|
| committer | Francis Whittle <FJ.Whittle@gmail.com> | 2019-06-16 21:59:16 +1000 |
| commit | bcdef5ae4f5ddf92285c1c93d0012d530ee8c352 (patch) | |
| tree | 56945c9a9418c63c30d09c159ba6d5d2128ff1be | |
| parent | 509b1323f0a7ee460e66b31d354b1d769a557f0b (diff) | |
| download | perlweeklychallenge-club-bcdef5ae4f5ddf92285c1c93d0012d530ee8c352.tar.gz perlweeklychallenge-club-bcdef5ae4f5ddf92285c1c93d0012d530ee8c352.tar.bz2 perlweeklychallenge-club-bcdef5ae4f5ddf92285c1c93d0012d530ee8c352.zip | |
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 { |
