Comments (3)
@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.
@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.
@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)
- too many repeat snippet HOT 1
- New Langage Library: Go HOT 3
- Firefox add-on missing HOT 1
- Interested in using Laravel/Vue Snippits? HOT 1
- Firefox addon doesn't work HOT 19
- New Langage Library: Java HOT 3
- typo in bubblesort
- Firefox link on https://30secondsofknowledge.com/ is broken HOT 1
- Feature request: Safari Extension HOT 2
- Could we add an installation and getting started guide? HOT 1
- Feature: System theme option
- Firefox addon doesn't work
- Can't find a function to export or syncing
- Chrome Extension settings min-width
- Old Design HOT 9
- Title cut off if too long HOT 3
- Wrong Function name while calling HOT 1
- Add Language Tag HOT 1
- Typo in footer HOT 1
- orthographic error in footer HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 30_seconds_of_knowledge.