4 ms·
How many function objects are created to generate that result? From a certain point of view, that is interesting too of course.
by xtho 16y ago
How many function objects are created to generate that result? From a certain point of view, that is interesting too of course.
- silentbicycle 16y agoWithout looking at the source: it could either generate a decision tree made of nested ifs and case statements (or the CPS equivalent), or it could just do a naive linear search over each list element. That's probably good enough until you have long lists of alternatives or structural matching against whole trees. I have a quick hack of a Lua library that does pattern matching with linear search. Whenever I get around to making it actually do analysis and compile search functions, I'll put it on github. (The patterns can have variable captures in them, too.)
- mnemonik 16y agoHere is the relevant code: http://github.com/fitzgen/wu.js/blob/master/lib/wu.js#L574 http://github.com/fitzgen/wu.js/blob/master/lib/wu.js#L574