loop-recur / lambdajs

142 stars 11 forks source link

reverse not defined for strings #7

Closed stefichjo closed 10 years ago

stefichjo commented 10 years ago

Hi!

Whereas reverse([1,2,3]) and reverse(['a','b','c']) work great, reverse("abc") doesn't.

Object abc has no method 'reverse'
    at _LambdaJS.reverse (/home/sts/node_modules/lambdajs/src/lambda.js:234:21)
    at repl:1:2
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)
    at ReadStream.EventEmitter.emit (events.js:98:17)

Your talks are very inspiring. Big fan!

DrBoolean commented 10 years ago

Thanks!

Since string's don't have a reverse function in standard js, i didn't include them, but I have mixed feelings about it.

I think we should bend the rules a little and give string reverse...but then where do we draw the line?

stefichjo commented 10 years ago

I see. Well, I just mentioned it because in the Motivation section of README.md you used this example:

var f = compose(reverse, replace(/-/g, '/'))
f("hi-guys") //=> syug/ih

Would have been a great Haskell-ish example though.

DrBoolean commented 10 years ago

Ha, I'm awesome. I'll update that for sure

DrBoolean commented 10 years ago

Updated! Thank ya kindly for helping out there.