Created
April 7, 2021 18:28
-
-
Save auxiliaire/65b238ce918bfc8f0e89f3b5e955dbf0 to your computer and use it in GitHub Desktop.
Implement `drop` in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function drop(...$args) { | |
| return curry(fn($n, $xs) => match (true) { | |
| is_string($xs) => substr($xs, $n), | |
| is_array($xs) => array_slice($xs, $n), | |
| default => null | |
| })(...$args); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment