Skip to content

Simple Input and Output

Landon Powell edited this page Aug 27, 2016 · 2 revisions

Output

When you're writing a program, you're probably going to want to be able to see some output. Maybe it's because you're debugging, and maybe it's because you're just curious what function is returning what.

The out or o function

The out function stylizes and prints information datatypes to the console.

With the str (aka string) datatype, it simply returns the first argument it gets and outputs it.

With the file datatype, it outputs the filename and all lines of a file with line numbers, and it optionally allows you to specify which lines to print using an extra argument. 0 for the file name, 1 for line 1, etc.

With the website datatype, it stylizes and outputs the domain, header information, and content from a website, and it allows you to use it's second argument to specify which of these pieces of information you want using a string.

If it doesn't fit any of these datatypes, it just prints it like a string.

The print or p function

The print function simply takes all it's arguments, and tosses them onto the display. No styling, no linebreaks, just pure evaluation and returning. Things that aren't strings or things which can be evaluated down to something else just get their name returned.

The rawOut function

If you thought print was simple, this just gives you the most simple version of the tree which can be outputted after evaluation. This is not an official DeviousYarn function, and is not required in an implementation, so you should only really use it for the sake of making debugging easier.

The cmd or term function

This command, much like rawOut, is not an official part of DeviousYarn and is not required in an implementation. In fact, there are nearly no excuses for ever using this function. This command takes a list of strings, and executes them as a shell command. It returns the output of the function as a string.

Input

Just as important as output, is input. If you want to be able to interface with your program, you'll need this.

The in function

This command takes a line of input from the user and returns it as a string. It's simple, it's easy, and it just werks.