Reads a number from stdin.
To start with,
O = 1. This allows placing of
O next to each other, whereas using
1 would be interpreted as the number 21 without a separating space (an unwanted extra character).
In Clip, the modulo function (
%) works on non-integers, so, to work out if some value
v is an integer, you check if
v mod 1 = 0. Using Clip syntax, this is written as
=0%v1. However, as booleans are stored as
1 (or anything else) and
0, checking if something is equal to
0 is just 'not'ing it. For this, Clip has the
! operator. In my code,
x is an input from stdin,
n converts a string to a number and
lab is log base
a. The program therefore translates (more readably) to
0 = ((log base 2 of parseInt(readLine)) mod 1).
Edit 1: replaced
Edit 2: replaced
Compresses the Clip version even further, as Pyth has Q for already evaluated input and a log2(a) function instead of just general log(a, b).
predfunction, when applied to an integer n, returns n - 1. Are functions such as this, which are thin disguises around the forbidden operator, also forbidden? \$\endgroup\$
), or most c-based languages'