Talk:MNNBFSL

From Esolang
Jump to navigation Jump to search

Some useful snippits of code

I'm hoping to be able to implement a TC language in MNNBFSL, so I've been looking for code that can standardize common operation. Each m and n, integers with m and n > 0 , represents the second and top values of the data stack respectively:

To calculate m+n:

 [->+<"][]

m*n:

 >>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<

m^n:

 ">>>[<[-"]<<-[>"<-"][]<-[>>>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<-"][][->+<"][]

For m%n (keep 0 < n < m for now):

 >">[<[-"]<[->+"<<<">[->>>-<<<"][]>>[<"[-"]++++++[>+++++++++<-"][]>]<<<">[->>>-<<<"][]>>  <"][]<[-"][]">>[-"]]<

m/n (Integer Division)

 [<[-"]>>">[<[-"]<[->+"<<<">[->>>-<<<"][]>>[<"[-"]++++++[>++++++++++<-"][]>]<<<">[->>>-<<<"][]<<+>>>>  <"][]<[-"][]">>[-"]]<+[-"][]<

Not n (Boolean)

 [<"[-"]+++++++++[->++++++++<"][]>"][<"[-"]+++++++[->++++++<"][]>+"]     [-"]

Each calculation is destructive, leaving only the result as the top value of the data stack (though any dstack and rstack value that isn't m or n is left untouched). --AndoDaan (talk) 22:09, 18 December 2014 (UTC)