Giter VIP home page Giter VIP logo

Comments (3)

petrovicstefanrs avatar petrovicstefanrs commented on July 18, 2024 1

@senky Welp I always forget that for a function to be a higher order function it only needs to accept a function as an argument not necessarily return a function as a result. (In my brain if it doesn't return a function its not a higher order function 😄) Anyway, keep it simple and change the name to actually mirror what the function does, okay like it! 😄

from 30_seconds_of_knowledge.

petrovicstefanrs avatar petrovicstefanrs commented on July 18, 2024

@senky Quite right you are! 😄 Will fix this! What do you think, I believe the code could be even shorter with return array_sum($operands). If I'm correct, and please do tell me if I'm wrong, the ... in php take all the arguments and put them in an array so this array_sum should technically work.
Still it would only work if parameters are numbers, otherwise a transformation function should be provided as a first parameter.

Hmmm now I'm a bit stumped, should I leave the example to work with numbers or should I expand it with a transformation function as well?

from 30_seconds_of_knowledge.

senky avatar senky commented on July 18, 2024

@petrovicstefanrs I wouldn't mix variadic functions with higher order functions. Also I wouldn't use array_sum as it breaks all the wonder. 😅 But maybe you could add more semantics:

function variadicSum(...$operands)
...

from 30_seconds_of_knowledge.

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.