Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

⚡️ λ PHP functional library focused on simplicity and performance

License

NotificationsYou must be signed in to change notification settings

Lambdish/phunctional

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phunctional, because functional programming matters.

LambdishMIT LicenseVersionMonthly DownloadsTravis Build Status

Lambdish's Phunctional is a little library that tries to bring to PHP some aspects of functional programing withutil high order functions andfunctions for manage iterables.


About

Phunctional is heavily inspired byClojure and some other PHP libraries likeiter,compose andfelpado.

The main principles that we have in mind developing this library are:

  • A collection can be any iterable PHP object, arrays or generators
  • Favor composition vs inheritance
  • Be lazy when you can
  • Avoid state, state is (usually) evil!
  • Simplicity over easiness
  • Break the above rules if it makes sense

All of this can be resumed with a word:Immutability.

Installation

To install it with composer:

composer require lambdish/phunctional

Simple usage

The first is to import every function you're going to use, for example:

usefunctionLambdish\phunctional\map;

And then you'll be able to use it:

map(function ($number) {return$number +10;    },    [1,2,3,4,5]);// => [11, 12, 13, 14, 15]

And do something more complex like:

usefunctionLambdish\Phunctional\pipe;useconstLambdish\Phunctional\{filter_null,reverse,first};$lastNonNullableValue =pipe(filter_null, reverse, first);$lastNonNullableValue(['first',null,'other','last non nullable',null,null]);// => "last non nullable"

Here we're using the provided constants, that acts like an alias for the functions full qualified namespace(and therefore, arecallable).

Documentation

You can find the functions documentationhere.

About

⚡️ λ PHP functional library focused on simplicity and performance

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors18

Languages


[8]ページ先頭

©2009-2025 Movatter.jp