My take at the challenge written in Elm
Source-Code
$ touch src/FriendList.elm
module FriendList exposing (friendList) surround : String -> String -> String -> String surround left right string = left ++ string ++ right toUpperTuples : String -> String toUpperTuples = String.split ":" >> List.reverse >> String.join ", " >> surround "(" ")" >> String.toUpper friendList : String -> String friendList = String.split ";" >> List.map toUpperTuples >> List.sort >> String.join ""
Unit test source-code
$ touch tests/FriendListTest.elm
module FriendListTest exposing (suite) import Expect import FriendList exposing (friendList) import Test exposing (Test) suite : Test suite = Test.describe "Friend list" [ Test.test "It should return the correct friend list" <| \_ -> let expectations = "(CORWILL, ALFRED)(CORWILL, FRED)(CORWILL, RAPHAEL)(CORWILL, WILFRED)(TORNBULL, BARNEY)(TORNBULL, BETTY)(TORNBULL, BJON)" friends = "Fred:Corwill;Wilfred:Corwill;Barney:Tornbull;Betty:Tornbull;Bjon:Tornbull;Raphael:Corwill;Alfred:Corwill" result = friendList friends in Expect.equal expectations result ]
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My take at the challenge written in Elm
Source-Code
Unit test source-code