maghoff / infix Goto Github PK
View Code? Open in Web Editor NEWAn implementation of infix notation for custom number types in JavaScript
Home Page: http://npmjs.com/package/infix
License: MIT License
An implementation of infix notation for custom number types in JavaScript
Home Page: http://npmjs.com/package/infix
License: MIT License
Using evaluate
is good for readability: the evaluated expression appears in the code where it is executed. Using compile
is good for execution speed: parsing of both the expression and the contained constants gets to happen ahead of time. The presumed "hot code path" is thus optimized.
Can we get both?
A memoizing evaluator could probably achieve a speedup when compared to evaluate
as well as an improvement in readability compared to compile
. It would look just like evaluate
but internally use some memoization, maybe like this:
var memoizedExpressions = {};
function memoizingEvaluator(expression, numberProvider) {
var f = memoizedExpressions[expression];
if (!f) f = memoizedExpressions[expression] = compile(expression, numberProvider);
return f();
}
The basic arithmetic syntax can be useful for accepting user input. For this use case, it is confusing that placeholders are accepted. infix
could offer a version of evaluate
which does not accept placeholders to solve this use case.
It makes less sense to have this version of the compiler. Compiled expressions mostly make sense with placeholders. So, it is sufficient only to implement the requisite evaluate
function.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.