From bcdef5ae4f5ddf92285c1c93d0012d530ee8c352 Mon Sep 17 00:00:00 2001 From: Francis Whittle Date: Sun, 16 Jun 2019 21:58:38 +1000 Subject: fjwhittle ch-3.p6 fixes after testing. --- challenge-012/fjwhittle/perl6/ch-3.p6 | 12 +++++++++--- 1 file 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 and die "API responded with error ‘$result’"; -my $synonyms = $result; +try { + my $synonyms = $result ~~ Array + ?? $result» + !! [$result]; -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 { -- cgit