daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const first = (array) => {
  2.   if(Array.isArray(array) && array.length > 0) {
  3.     return Maybe.Just(array[0])
  4.   } else {
  5.     return Maybe.Nothing()
  6.   }
  7. }
  8.  
  9. first([1]) == Maybe.Just(1)
  10. first([]) == Maybe.Nothing()
  11. first('ouch') == Maybe.Nothing()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top