Skip to main content
deleted 24 characters in body
Source Link
ankh-morpork
  • 1.5k
  • 1
  • 12
  • 15

Prolog (SWI), 116104 bytes

It worked out to be shorter to write directly to stdout inside the predicate. The more idiomatic way of implementing something like this in Prolog would be to have third parameter for the predicate which would be the output from interpreting the program.

+A:-string_codes(A,B),0+B. A+[E|T]:-E=35,!,C is A mod 127,char_codeput_code(D,C),write(D),0+T;E=59,!,B is A+1,B+T;A+T. _+[]. 

Try it online!Try it online!

Prolog (SWI), 116 bytes

It worked out to be shorter to write directly to stdout inside the predicate. The more idiomatic way of implementing something like this in Prolog would be to have third parameter for the predicate which would be the output from interpreting the program.

+A:-string_codes(A,B),0+B. A+[E|T]:-E=35,!,C is A mod 127,char_code(D,C),write(D),0+T;E=59,!,B is A+1,B+T;A+T. _+[]. 

Try it online!

Prolog (SWI), 104 bytes

It worked out to be shorter to write directly to stdout inside the predicate. The more idiomatic way of implementing something like this in Prolog would be to have third parameter for the predicate which would be the output from interpreting the program.

+A:-string_codes(A,B),0+B. A+[E|T]:-E=35,!,C is A mod 127,put_code(C),0+T;E=59,!,B is A+1,B+T;A+T. _+[]. 

Try it online!

Source Link
ankh-morpork
  • 1.5k
  • 1
  • 12
  • 15

Prolog (SWI), 116 bytes

It worked out to be shorter to write directly to stdout inside the predicate. The more idiomatic way of implementing something like this in Prolog would be to have third parameter for the predicate which would be the output from interpreting the program.

+A:-string_codes(A,B),0+B. A+[E|T]:-E=35,!,C is A mod 127,char_code(D,C),write(D),0+T;E=59,!,B is A+1,B+T;A+T. _+[]. 

Try it online!