-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I found a library called pampy.js that provides a very concise syntax for pattern matching. If this library were translated into PHP, then functional-php's pattern matching might look like this, using a variadic function to match patterns instead of an array:
function fib($n) {
return match($n,
1, 1,
2, 1,
_, function($x){ return fib($x - 1) + fib($x - 2); }
//each underscore is passed as an argument to a function, so there can be several
);
}
Would it be possible to translate pampy.js to PHP so that the patterns could be matched in this way?
Metadata
Metadata
Assignees
Labels
No labels