Giter Site home page Giter Site logo

Introduce while loops about nx HOT 3 CLOSED

elixir-nx avatar elixir-nx commented on May 5, 2024 2
Introduce while loops

from nx.

Comments (3)

josevalim avatar josevalim commented on May 5, 2024 1

After thinking more about this, I suggest for us to start with while only and make it clear it is a sequential construct. We can explore something like for in the future.

from nx.

seanmor5 avatar seanmor5 commented on May 5, 2024

I am a fan of futhark so I think adding their style of looping is definitely an interesting idea. In terms of adding map, map_with_index, reduce and reduce_with_index, I am confident in being able to do that with EXLA.

Understanding that the for+:reduce concept might be foreign/unfamiliar to new users, I am curious if maybe it's a good idea to include both options for users who want their code to be closer to what a normal Elixir program might support?

from nx.

josevalim avatar josevalim commented on May 5, 2024

@seanmor5 that's a good question. I went back to Furhark code and I realized the support two looping constructs: for and while:

loop x while x >= 1
loop x for y in expr

If we want to support both loops, then it means this is not quite the same as for+:reduce. I think we can support while loops like this:

loop x, x >= 0 do
  x - 1
end

So I would rather proceed with loop and then if people think this is a good idea, we can even consider having it as part of Elixir?

from nx.

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.