Jelly uses tapes. Sequential tapes and only two types of loops:
One checks if data value is zero then moves forward until matched, other checks if data value is not zero then moves backward until matched.
All loops must be running by compare the value at tape with [ and ] and increment or decrement a counter, forward or backward a step, until counter is zero.
As pseudo code shows, both loops only differs at forward and backward move.
By using a byte as counter, a maximum nested loops is 255.
how make nested [ and ] ?
// for [
cnt=0;
do {
if (*dp == ‘[‘ ) cnt++;
if (*dp == ‘]’ ) cnt--;
dp++;
}while (cnt);
// for ]
cnt=0;
do {
if (*dp == ‘]‘ ) cnt++;
if (*dp == ‘[’ ) cnt--;
dp--;
}while (cnt);
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.