Skip to content

Instantly share code, notes, and snippets.

@auxiliaire
Created April 7, 2021 18:28
Show Gist options
  • Select an option

  • Save auxiliaire/65b238ce918bfc8f0e89f3b5e955dbf0 to your computer and use it in GitHub Desktop.

Select an option

Save auxiliaire/65b238ce918bfc8f0e89f3b5e955dbf0 to your computer and use it in GitHub Desktop.
Implement `drop` in PHP
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