Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manuels/matlab-scoreunder
underscore/scoreunder for matlab
https://github.com/manuels/matlab-scoreunder
Last synced: about 1 month ago
JSON representation
underscore/scoreunder for matlab
- Host: GitHub
- URL: https://github.com/manuels/matlab-scoreunder
- Owner: manuels
- License: gpl-2.0
- Created: 2013-09-10T07:39:31.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-09-10T08:28:46.000Z (over 11 years ago)
- Last Synced: 2024-10-15T22:07:03.364Z (3 months ago)
- Size: 121 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
matlab-scoreunder
=================This library is for everyone who hates matlab just as deeply as I do. It brings some functions for functional programming from [underscore](http://underscorejs.org/)/[lowdash](http://lodash.com/)/[scoreunder](https://github.com/loop-recur/scoreunder) to matlab.
Note that its paragon is scoreunder that means that it aims to support lowdash functions (where it makes sense) but the arguments of all functions are reversed!Getting Started
===============
After downloading/cloning the library and adding it to the search path of matlab (using `addpath`) you can use scoreunder like this>> u = scoreunder();
>> square = @(x) x*x;
>> u.map2matrix(square, 1:5)
[1, 4, 9, 16, 25]Auto-Curried Functions
======================
Underscore's functions are auto-curried where it makes sense. See [Brian Lonsdorf's presentation](https://www.youtube.com/watch?v=m3svKOdZijA) to understand why.
That means that arguments are curried (bound) to functions if you call the function with less arguments than it needs to evaluate:>> square = @(x) x*x;
>> squareElements = u.map2matrix(square);
>> squareElements(1:5)
[1, 4, 9, 16, 25]
>> add = @(x,y) x+y;
>> squareSum = u.compose(u.reduce(add, 0), squareElements)
55Map/Reduce
==========
`map2xxx(fn, collection)` and `reduce(fn, init, collection)` are agnostict with respect to the type of their collection argument but map is not with respect to its output type:>> square = @(x) x*x;
>> map2matrix(square, [1,2,3])
[1, 4, 9]
>> map2matrix(square, {1,2,3})
[1, 4, 9]
>> map2cell(square, [1,2,3])
{1, 4, 9}
>> map2cell(square, {1,2,3})
{1, 4, 9}
>> add = @(x,y) x+y;
>> mysum = u.reduce(add, 0, 1:3);
6More functions
==============
For more functions supported by scoreunder and how to use them checkout the [`test.m`](https://github.com/manuels/matlab-scoreunder/blob/master/test.m) filefieldnames(scoreunder())
'autoCurry'
'curry'
'compose'
'identity'
'isMatrix'
'isArray'
'isCell'
'isTrue'
'isFalse'
'map2cell'
'map2matrix'
'map2array'
'reduce'
'filter'
'ifThenElse'
'first'
'rest'
'zip'
'flatten'Help Developing
===============
I'm more than welcome for pull requests. However, note that every new feature must include tests in [`test.m`](https://github.com/manuels/matlab-scoreunder/blob/master/test.m) that check and describe them.