Giter Site home page Giter Site logo

TdE 20170705 about ppl HOT 3 OPEN

leadermaxone avatar leadermaxone commented on August 18, 2024
TdE 20170705

from ppl.

Comments (3)

leonardoarcari avatar leonardoarcari commented on August 18, 2024

In my understanding of the exercise, and I quote the exercise text, reversing a tree means

“reversing” all the values in the leaves

and not having a tree which is symmetrical to the input one.

Therefore, I believe that Nil should not be taken into account. Nil in my opinion stands for there's no branch here, it shouldn't be considered as a value.
So the solution should be correct as, by construction, all the leaves' values appear in reverse order.

from ppl.

riccardotommasini avatar riccardotommasini commented on August 18, 2024

I agree with @leonardoarcari , i think Nil has no value, is a nullary data constructor and it should stay where it is.

If you check the example, the returned tree is isomorphic to the input one, and only the values are
reversed.

Moreover, in 1.3 there's no mention of it. Did you try the proposed solution?

from ppl.

leadermaxone avatar leadermaxone commented on August 18, 2024

yes of course,

Unless I understood something wrong, the revtree of a tree like

let t3 = (Branch (Branch (Leaf 3) (Leaf 4)) (Branch Nil (Leaf 5)))

should be

(Branch (Branch (Leaf 5) Nil) (Branch (Leaf 4) (Leaf 3)))

while the above solution gives

Branch (Branch (Leaf 5) (Leaf 4)) (Branch Nil (Leaf 3))

this was executed with the proposed solution.
It's only that, in my mind,when i tried reversing t3 as mentioned I treated Nil as a value and swapped it around as well (on paper).

With the proposed solution t3 reversed is not isomorphic anymore...but probably my definition of isomorphism is wrong because it takes into account Values and Nil as well.

Anyways, it appears I was making the problem more difficult than what it was.
Thanks!

from ppl.

Related Issues (12)

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.