Skip to content

Commit

Permalink
Add readTsvFile
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchpaulus committed Dec 11, 2024
1 parent 751bfff commit 11bebf5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
1 change: 1 addition & 0 deletions doc/mshell.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down
6 changes: 6 additions & 0 deletions lib/std.msh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 11bebf5

Please sign in to comment.