This is probably my favorite Brachylog program (most likely because it is twice as short as the Jelly answer on this challenge! it is twice as short as the Jelly answer on this challenge!). This is a program which palindromizes its input.
This is probably my favorite Brachylog program (most likely because it is twice as short as the Jelly answer on this challenge!). This is a program which palindromizes its input.
This is probably my favorite Brachylog program (most likely because it is twice as short as the Jelly answer on this challenge!). This is a program which palindromizes its input.
###Length 9
This program computes the digital root of its input.
Just like in Prolog, we can write multiple rules for a single predicate, using |: the first rule #0 constrains the Input = the Ouput to be a single digit. If this is not possible, the second rule @e+:0& will split the input as a list of digits, then sum them and call Predicate 0 (the main predicate) recursively.
###Length 9
This program computes the digital root of its input.
Just like in Prolog, we can write multiple rules for a single predicate, using |: the first rule #0 constrains the Input = the Ouput to be a single digit. If this is not possible, the second rule @e+:0& will split the input as a list of digits, then sum them and call Predicate 0 (the main predicate) recursively.