function addContents() { $addContents = function ($name, $parts) { $names = F\filter(F\notEq($name), F\map(F\get('name'), $parts)); var_dump($names); $contents = F\map(function ($partname) use($name) { $link = URL . "/docs/{$name}.md#{$partname}"; return "- [{$partname}]({$link})"; }, $names); file_put_contents("docs/README.md", F\join("\n\n", F\concat(["## {$name}"], $contents)) . "\n\n", FILE_APPEND); return array_merge(['# ' . $name, '## Table Of Contents'], $contents, F\map(F\get('md'), $parts)); }; return F\apply(F\curry($addContents), func_get_args()); }
public function test_concat() { $this->assertEquals(F\concat([1, 2], [3, 4]), [1, 2, 3, 4]); $this->assertEquals(F\concat('Hello ', 'World'), 'Hello World'); }