diff --git a/stdlib-candidate/README.md b/stdlib-candidate/README.md new file mode 100644 index 00000000..4c849718 --- /dev/null +++ b/stdlib-candidate/README.md @@ -0,0 +1,4 @@ +# std-lib candidate + +This folder is where we can add scripts that might want to be in std-lib at some point. It can serve both as a holding place for scripts that are waiting on nushell changes, as well as a place to develop and discuss such scripts. + diff --git a/stdlib-candidate/str.nu b/stdlib-candidate/str.nu new file mode 100644 index 00000000..fe5a8d47 --- /dev/null +++ b/stdlib-candidate/str.nu @@ -0,0 +1,16 @@ +def "str append" [tail: string]: [string -> string, list -> list] { + let input = $in + match ($input | describe | str replace --regex '<.*' '') { + "string" => { $input ++ $tail }, + "list" => { $input | each {|el| $el ++ $tail} }, + _ => $input + } +} +def "str prepend" [head: string]: [string -> string, list -> list] { + let input = $in + match ($input | describe | str replace --regex '<.*' '') { + "string" => { $head ++ $input }, + "list" => { $input | each {|el| $head ++ $el } }, + _ => $input + } +}