diff --git a/DEVELOP.md b/DEVELOP.md index 8c43201..534426d 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -71,3 +71,4 @@ MShellObject ## References [fish shell built in](https://github.com/fish-shell/fish-shell/tree/master/src/builtins) +[Stroustrop's Rule](https://buttondown.com/hillelwayne/archive/stroustrops-rule/) diff --git a/doc/mshell.md b/doc/mshell.md index 9af1d29..b5c514d 100644 --- a/doc/mshell.md +++ b/doc/mshell.md @@ -21,6 +21,7 @@ - `cd`: Change directory `(string -- )` - `toFloat`: Convert to float. `(numeric -- float)` - `readFile`: Read file into string. `(string -- string)` +- `readTsvFile`: Read a TSV file into list of list of strings. `(string -- list[list[string]])` - `stdin`: Drop stdin onto the stack `( -- string)` - `..`: Drop stdin onto the stack and split by lines `( -- list[string])` - `foldl`: Fold left. `(quote initial list -- result)` diff --git a/lib/std.msh b/lib/std.msh index f3df728..18841d7 100644 --- a/lib/std.msh +++ b/lib/std.msh @@ -116,6 +116,12 @@ def abs [(dup 0 <) (-1 *)] if end + def tab " " end def tsplit tab split end def uw unlines w end + +# readTsvFile (str -- list[list[str]]) +def readTsvFile + readFile lines (tsplit) map end +end