Skip to content

Commit

Permalink
better takeWhile definition
Browse files Browse the repository at this point in the history
  • Loading branch information
gkz committed Jun 12, 2012
1 parent 147dacd commit 16281aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions prelude.ls
Expand Up @@ -204,11 +204,11 @@ exports.splitAt = splitAt = (n, xs) --> [(take n, xs), (drop n, xs)]
exports.takeWhile = takeWhile = (p, xs) -->
return xs if not xs.length
p = objToFunc p if typeof! p isnt \Function
i = 0
result = []
for x in xs
break if not p x
++i
take i, xs
result.push x
if typeof! xs is \String then result.join '' else result

exports.dropWhile = dropWhile = (p, xs) -->
return xs if not xs.length
Expand Down

0 comments on commit 16281aa

Please sign in to comment.