You are viewing ivan_gandhi

Из-Под Глыб - right reduction in js

Mar. 2nd, 2009

03:47 pm - right reduction in js

Previous Entry Share Next Entry

concat is probably the only function I could use to do some kind of reduction in js; actually, js people could care more about the opportunities to use functional programming style; I wonder why they did not.

function stacktrace() { 
  function st2(f) {
    return !f ? [] : 
        st2(f.caller).concat([f.toString().split('(')[0].substring(9) + '(' + f.arguments.join(',') + ')']);
  }
  return st2(arguments.callee.caller);
}

Comments:

[User Picture]
From:cema
Date:March 3rd, 2009 12:50 am (UTC)
(Link)
Does not jQuery suggest the functional style?
(Reply) (Thread)
[User Picture]
From:ivan_gandhi
Date:March 3rd, 2009 01:17 am (UTC)
(Link)
Oh. Thanks a lot!!! I just did not know.
(Reply) (Parent) (Thread)
[User Picture]
From:cema
Date:March 3rd, 2009 04:48 am (UTC)
(Link)
What do you mean? It was just a question. Am I right, or is it simply that the people who use jQuery tend to be, say, smart enough to use the functional style as well?
(Reply) (Parent) (Thread)
[User Picture]
From:ivan_gandhi
Date:March 3rd, 2009 06:00 am (UTC)
(Link)
I just wanted to thank you for the hint. I never used jQuery; so I understood that it does contain the necessary language tools.
(Reply) (Parent) (Thread)
[User Picture]
From:cema
Date:March 3rd, 2009 11:59 am (UTC)
(Link)
Actually, yes, they explicitly say so in the docs (and call it the Builder pattern). I am somewhat stale on the details.
(Reply) (Parent) (Thread)