Giter Site home page Giter Site logo

Stack class about feat HOT 4 CLOSED

cavalab avatar cavalab commented on September 18, 2024
Stack class

from feat.

Comments (4)

tilakhere avatar tilakhere commented on September 18, 2024

commit 40f28e4

Since overloading operator[] could not guarantee different return types hence instead of stack['f'] or stack['b'], stack.f and stack.b are supported.

from feat.

lacava avatar lacava commented on September 18, 2024

Some questions and comments on 40f28e4 :

  • Can you do ArrayXb x = stack.pop() and have it return an element from the correct stack?
  • It would be nice to wrap the stack/node check into a Stack class method. so that
    (stack.f.size() >= n->arity['f'] && stack.b.size() >= n->arity['b'])
    would become something like stack.check(n) and you could define
    bool Stack::check(Node & n) { return stack.f.size() >= n->arity['f'] && stack.b.size() >= n->arity['b'];}
    then we could update the check function in one place as we add /change the stacks.
  • the stack name "l" is not nice .. it's hard to read lower case l names. please rename it to 'z' or 'long'.
  • for most simple functions (like add) we can simplify the code from
ArrayXd x2 = stack.f.pop();
ArrayXd x1 = stack.f.pop();
stack.f.push(limited(x1 + x2));

to stack.f.push(limited(stack.f.pop() + stack.f.pop()));

from feat.

tilakhere avatar tilakhere commented on September 18, 2024

@lacava

commit 409c0dd

  • ArrayXb x = stack.pop() cannot be implemented to return element from correct stack as we need to specify return type in pop() function definition which cannot be generic. Thats why implemented stack.f, stack.b and stack.z. Let me know if you can think of a way this can be improved.

  • stack.check(arity) method implemented. Instead of using the whole Node& have used node->arity data member reference as parameter as then stack class would depend on node class and node already is dependent on stack class which would create a cyclic dependency.

  • replaced stack.l with stack.z everywhere

  • simplified nodes' evaluate() and eval_eqn()

from feat.

lacava avatar lacava commented on September 18, 2024

PR #94 merges this into master

from feat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.