Giter VIP home page Giter VIP logo

Comments (9)

9il avatar 9il commented on August 28, 2024

See also #9

from mir.

wilzbach avatar wilzbach commented on August 28, 2024

Hmm I like your idea of overloading opCall, but it works only for element access.
What do you think about something like the following?
(the last two are proposed)

It should basically work similar to opIndex then ;-)

auto s = iota(4).sliced(2,2);
s[].writeln; // [[0, 1], [2, 3]]
s().writeln; // [0, 2], [1, 3]]
s(1).writeln; // [[0,2]]

from mir.

9il avatar 9il commented on August 28, 2024

Hmm I like your idea of overloading opCall, but it works only for element access.

Yes, first we need a good DIP for opCall to be like opIndex. See http://wiki.dlang.org/DIPs

It should basically work similar to opIndex then ;-)

Behavior with .writeln looks bad to me. opCall should only select sub-dimensions without any transpostion.

from mir.

wilzbach avatar wilzbach commented on August 28, 2024

Yes, first we need a good DIP for opCall to be like opIndex. See http://wiki.dlang.org/DIPs

I guess one could use iota instead of .., apart from that variadic arguments should be supported ;-)

Behavior with .writeln looks bad to me. opCall should only select sub-dimensions without any transpostion.

What would you suggest s(1) should return then?

from mir.

9il avatar 9il commented on August 28, 2024

I guess one could use iota instead of .., apart from that variadic arguments should be supported ;-)

Anyway $ is not defined for opCall

What would you suggest s(1) should return then?

s().writeln; // [[0, 1], [2, 3]] instead of [[0, 2], [1, 3]]
s(1).writeln; // [0, 2] instead of [[0,2]]

from mir.

wilzbach avatar wilzbach commented on August 28, 2024

Anyway $ is not defined for opCall

You could also overload with tuples and replace the $ with -1

s = iota(9).sliced(3, 3);
// 0 1 2
// 3 4 5
// 6 7 8

// 0 3 6
// 1 4 7
// 2 5 8
s(tuple(1,2), tuple(1, 2)); // [[4,7], [5,8]]
s( tuple(1,-1), tuple(1, -1)); // same

Oh sry - made the brackets for s(1) by mistake.

For s() I am not sure yet, but by looking at the examples with everted above, I notice two things

b.everted.reshape(2, 3).everted
b().reshape(2, 3)(); // similar, but definitely harder to read
  1. the opCall syntax is quite hard to distinguish/read and to understand whats going on. Why not add a simple method, e.g. b.F(2, 3) (probably better naming required though)

  2. The main point of this issue was that in the examples the math index order is not stored, leading that b.everted.reshape(2, 3).everted evaluates differently than maybe expected and one needs to make a copy of the array..

from mir.

9il avatar 9il commented on August 28, 2024

You could also overload with tuples and replace the $ with -1

-1 would significantly reduce performance.

from mir.

wilzbach avatar wilzbach commented on August 28, 2024

-1 would significantly reduce performance.

and if i think about it one couldn't do stuff like (2, $-3)

from mir.

9il avatar 9il commented on August 28, 2024

duplicate of #10

from mir.

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.