Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print newline in Fish (the programming language)?

I'm having trouble with the fish programming language wherein I cannot make a single (or, in fact, any length of) character (not including quotes) new line. Not even regex works for this. As it is a 2-D Programming Language, a new line breaks the code - it doesn't execute as intended. My code is a modified fibonacci sequence generator as shown on the wiki page, but uses literal spaces to print to the command line. It is below, if this helps in any way:

0:n" "o1:nv
 n:+@:o" "<

So, my question is this: is there a newline character or series of characters that I can use instead of the spaces? Should I pursue a different new line procedure (i.e. running as many outputs as I need to a file and THEN changing them all to new lines)?

like image 833
Addison Crump Avatar asked Oct 06 '15 08:10

Addison Crump


1 Answers

Looked a little harder and cleared my eyes, and, after looking at an ASCII table and examining stacks in Fish, I realized my answer was as simple as this:

ao;

The reasoning behind this Fish stores characters in the stack as numbers. Therefore, loading the number 10 (Fish accepts hexadecimal in src) into the stack and then printing it with o (simple character output) prints a carriage return.

Therefore, my code becomes:

0:nao1:nv
 n:+@:oa<

That was so obvious it hurt after I did that. Hopefully this helps someone else in the future.

like image 127
Addison Crump Avatar answered Jan 02 '23 20:01

Addison Crump