Beispiel #1
0
function keywords($data)
{
    if (!isset($data->code)) {
        return [];
    }
    $size = strpos($data->code, '(');
    if ($size === false) {
        $size = strlen($data->code);
    }
    $keywords = F\pipe(F\take($size), F\split(' '), F\map('trim'), F\filter(F\notEq('')));
    return $keywords($data->code);
}
Beispiel #2
0
 public function test_take()
 {
     $items = ['Foo', 'Bar', 'Baz'];
     $this->assertEquals(['Foo', 'Bar'], F\take(2, $items));
     $this->assertEquals([], F\take(0, $items));
     $this->assertEquals(['Bar', 'Baz'], F\take(-2, $items));
     $this->assertEquals('Hello', F\take(5, 'Hello World'));
     $this->assertEquals('World', F\take(-5, 'Hello World'));
 }