MSM, 31 bytes
'?ddF',',',.....T',',':'?....':
MSM is stack based, so the two input numbers are expected to be on top of the stack, i.e. on the right of the string. MSM has neither numbers nor booleans so we are free to choose a (reasonable) representation:
T True
F False
123 numbers are just sequences of ascii digits. There's no literal
representation in MSM source code, so you have to construct them
digit by digit: 321.. -> 123 (remember: . is concatenation)
TIO doesn't support MSM out of the box, so I've included the JS interpreter from the esolang page.
Try it online!
How it works: (I use a
and b
for the two numbers on the stack).
Excerpt from the MSM command reference:
' quote, push next char on the stack, even if it is a command
? skip next command if the two top elements of the stack are equal
, drop
: expand string at top of the stack and push each char of it on the stack
. concatenate two top elements
everything else is pushed
Stack trace:
' ? d d F ' , ' , ' , . . . . . T ' , ' , ' : ' ? . . . . ' : a b
d d F ' , ' , ' , . . . . . T ' , ' , ' : ' ? . . . . ' : a b ?
The next 6 chars are pushed on the stack and concatenated with 5 dots
T ' , ' , ' : ' ? . . . . ' : a b ? ,,,Fdd
The next 5 chars are pushed on the stack and concatenated with 4 dots
' : a b ? ,,,Fdd ?:,,T
:
and the two numbers are pushed
? ,,,Fdd ?:,,T : a b
Now it gets interesting. If the two numbers are equal, ,,,Fdd
is skipped
?:,,T : a b -- ?:,,T as a whole is not a command, so it's pushed
: a b ?:,,T -- expand
a b ? : , , T -- push a b
? : , , T a b -- a b are still equal, so skip :
, , T a b -- drop a b
T -- MSM stops, output is True
If the two numbers are not equal, don't skip ,,,Fdd
, but push it:
,,,Fdd ?:,,T : a b
: a b ,,,Fdd ?:,,T -- expand
a b ,,,Fdd ? : , , T -- push up to ?
? : , , T a b ,,,Fdd -- number b is never equal to ,,,Fdd so expand
, , T a b , , , F d d -- drop two dummy values
T a b , , , F -- push T a b
, , , F T a b -- drop b a T
F -- stop
int
. It only makes sense when talking about string representation of numbers, or with decimal floating point (en.wikipedia.org/wiki/Decimal_floating_point) where the bit pattern representing the number uses base 10, not base 2. Or maybe a BCD integer. IIRC, IBM's POWER architecture has decimal float support, which is useful for some financial stuff, but most architectures only have IEEE binary32 / binary64. But anyway, a numeric type is probably best described as a binary integer, or simply "an integer". \$\endgroup\$