+ 1
Knuth's Up-Arrow Notation
https://en.m.wikipedia.org/wiki/Knuth%27s_up-arrow_notation Knuth's up-arrow notation, written as "↑" or "^", is an operator used to make large numbers. This operator works as follows: a↑b = a*a*...*a (b "a"s) a↑↑b = a↑a↑...↑a (b "a"s) ... Take 2↑↑↑4 as an example: 2↑↑↑4 = 2↑↑2↑↑2↑↑2 = 2↑↑2↑↑(2↑↑2) = 2↑↑2↑↑(2↑2) = 2↑↑2↑↑4 = 2↑↑(2↑↑4) = 2↑↑(2↑2↑2↑2) = 2↑↑(2↑2↑4) = 2↑↑(2↑16) = 2↑↑65536 = 2↑2↑...↑2 (total 65536 "2"s) Is it possible to do it and output the result as a string?
1 Respuesta
+ 1
totally possible.
First, write a tokenizer that spews out the numbers, arrows and nothing else. Avoid decimals for the first version.
From the tokenizer's output, the parser will take over. Our grammar is quite simple here. number [ [^+] number]* is all for now.
once the parser clears the input, evaluate, call to string on it, and print it out!
simples