6 kyu

Sum of list of Integer Just's and Nothing's

120 of 148wichu

Description:

Your task is to write a function sumJusts that will take a list of Maybe Integer (PureScript: Maybe Int) elements and return a Just element with boxed value of sum of all list items.

List may contain Nothing elements. If so, treat Nothing as Just 0.

You may assume the list is nonempty. As such, your solution need not consider this case (though you could if you wanted to) - this is reflected in PureScript by the Partial type class constraint on the function signature of sumJusts.

For example:

sumJusts [Just 1, Just 2] = Just 3
sumJusts [Just 1, Just 2, Nothing] = Just 3
unsafePartial sumJusts (Just 1 : Just 2 : Nil) -- => Just 3
unsafePartial sumJusts (Just 1 : Just 2 : Nothing : Nil) -- => Just 3
Fundamentals

Stats:

CreatedSep 15, 2016
PublishedSep 15, 2016
Warriors Trained260
Total Skips14
Total Code Submissions370
Total Times Completed148
Haskell Completions120
PureScript Completions36
Total Stars5
% of votes with a positive feedback rating91% of 48
Total "Very Satisfied" Votes42
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes3
Total Rank Assessments11
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • wichu Avatar
  • donaldsebleung Avatar
  • JohanWiltink Avatar
  • cliffstamp Avatar
  • solitude Avatar
Ad