Talk:Nellephant
Jump to navigation
Jump to search
Cat Program
Would this be a valid cat program in Nellephant?
CRASH {
attract 0 0
}
# First, set up a counter
# :cnt_l is the left pointer and current value
# :cnt_r is the right pointer and next value
attract :cnt_r 1
# cnt_l starts at 0
# cnt_r starts at 1
handle :loop
:copy_query query :cnt_l # JMP if 0
# Didn't jump, bit is 1
output '1
:copy_crash CRASH # JMP end
# Jumped, bit is 0
handle :copy_query
output '0
handle :copy_crash
repel :cnt_l :cnt_r # Increment :cnt_r by 1
:end_loop attract 3 :cnt_r # Crashes if cnt_r == 3 == End of input array
repel 3 :cnt_r # Revert last line if it didn't crash
attract :cnt_r :cnt_l # Increment :cnt_l by 1
:loop CRASH
handle :end_loop
-- Davipb (talk) 13:06, 5 August 2019 (UTC)
Regular expresion output
One idea I have of a variant is: Add a command to test if the output matches a regular expression; if it does not match then the thread is removed without possibility of being handled. Maybe also add a command that does if it does match instead of if it does not match. --Zzo38 (talk) 06:12, 6 June 2021 (UTC)