vector-php / vector Goto Github PK
View Code? Open in Web Editor NEWA PHP functional programming library.
License: MIT License
A PHP functional programming library.
License: MIT License
A few things have changed since the functional basics page was written - go back through and update terminology, method names, and module names.
sequence :: Monad m => [m a] -> m [a]
Convert a list of monad into a monad of list
This is low hanging fruit for optimization. When calling Module::using() in multiple places and requesting the same function, memoize and store the result of the internal reflection call so that a single reflection is never duplicated.
product :: [Num] -> Num
Returns the product of the given list
negate :: Num -> Num
Returns the given number * -1
Add tests
dropWhile :: (a -> Bool) -> [a] -> [a]
Returns the list sans the first elements that pass the given test
Add tests
all :: (a -> Bool) -> [a] -> Bool
Returns true if every element of [a] passes the given test.
drop :: Int -> [a] -> [a]
Returns the given list sans the first n elements
not :: Bool -> Bool
Logical not
indexOf :: a -> [a] -> Maybe Int
Finds the index of the given element
Add tests
Add tests
min :: Num -> Num -> Num
Returns the minimum of its two arguments
flatten :: [a] -> [b]
Flattens nested arrays
max :: Num -> Num -> Num
Returns the maximum of its two arguments
append :: a -> [a] -> [a]
Append a to [a]
trim :: String -> String
Returns a string with leading and trailing whitespace removed
findIndex :: (a -> Bool) -> [a] -> Maybe Int
Attempts to find an element's index by using a given test
toUpper :: String -> String
Returns a string in uppercase
dropLastWhile :: (a -> Bool) -> [a] -> [a]
Returns the list sans the last elements that pass the given test
takeWhile :: (a -> Bool) -> [a] -> [a]
Take items from a list while a given test passes
and :: Bool -> Bool -> Bool
Logical and
adjust :: (a -> a) -> Int -> [a] -> [a]
Applies a function to the value at a given index.
Right now it only works with Applicative Functors interface-ing classes.
It should be overridden similar to Control\Functor::fmap to work with arrays, since [] is technically applicative.
call :: String -> Object -> a
Call the method String on the given Object and return its result
foldl :: (b -> a -> b) -> b -> [a] -> b
Reduce left
reverse :: [a] -> [a]
Reverse a list
take :: Int -> [a] -> [a]
Take n items from a list
find :: (a -> Bool) -> [a] -> Maybe a
Attempts to find an element by using a given test
takeLast :: Int -> [a] -> [a]
Take n items from a list starting at the back
unique :: [a] -> [a]
Return an array with duplicates removed
The module lacks documentation. Things that should be covered in the docs:
mod :: Int -> Int -> Int
Modulus operator, divisor is first argument
repeat :: a -> Int -> [a]
Repeat the given item n times
any :: (a -> Bool) -> [a] -> Bool
Returns true if any element of [a] passes the given test
Add tests
Add tests
or :: Bool -> Bool -> Bool
Logical or
range :: Int -> Int -> [Int]
Returns all integers between the given arguments, inclusive
zip :: [a] -> [b] -> [[a, b]]
Zip two lists together into a 2-d array pairwise
foldr :: (a -> b -> b) -> b -> t a -> b
Reduce right
sum :: [Num] -> Num
Returns the sum of the given list
Add tests
contains :: a -> [a] -> Bool
Returns true if [a] contains a
dropLast :: Int -> [a] -> [a]
Returns the given list sans the last n elements
[] is a monad, so bind and kleisli compose should both work with it similar to how Control\Functor::fmap works with arrays.
Add tests
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.