Using modulus to simplify input
This might be too simple of a tip, so if it is I'll just replace it or delete it.
Let's say you want to take input of two characters, "a" and "b" and return 1, and 2 for each, respectively. You'd probably use conditionals for this, since it makes the most sense, and I'll be using a more condensed form for this specific example.
i:"a")+1+n
This checks to see if the input is greater than "a" and adds 1. Since "a" will return 0 and "b" 1, this will give 1 and 2. This does the job pretty well, but in the case of our inputs, we could go even further.
i:3%n
In mod 3, 97, which is "a"s numerical equivalent, becomes 1, and 98, which is "b"s, becomes 2. For two different numbers, there is guaranteed a mod which gives unique results for both. For more than two, there is a mod that gives unique results, but I don't have the mathematical prowess to find the smallest one in a simple way (e.g. if you have the set {100,101,102,103}, mod 104 would give unique results for each value in it but not in a very helpful fashion). However, in most cases, with input being restricted to a couple alphabetical characters, you can often find a mod that works.
To find the smallest modulus that yields unique results for two numbers, a, and, b, you do as follows. Take the absolute value of the difference of a and b (|a - b|
) and find the smallest number, n, which does not divide it. e.g. for 97 and 98, |98 - 97| = 1
, and so 2 would be the smallest mod (but for our test program, this gives 1 for 97 and 0 for 98, so mod 3 is better).
9I just realized while looking at the esolang page: the creator of ><> has a name that might sound like "harpoon". – mbomb007 – 2015-02-24T15:32:27.783
How can I print a new-line in fish? – Captain Man – 2015-06-29T22:09:53.443
@CaptainMan You can output code points with
o
, and since newline\n
is ASCII 10 you can doao
. – Sp3000 – 2015-06-30T01:32:47.080@Sp thanks, I was trying
CR
instead ofLF
and was pushingd
instead ofa
. – Captain Man – 2015-06-30T01:39:24.447