180 likes | 185 Views
This animation showcases the implementation of Stepanov's do_cycle function from Notes on Programming. The function iterates through a cycle of elements and performs a given action on each element.
E N D
Animation of Stepanov’s do_cycle function, from Notes on Programming, Lecture 17 i a b c d void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
next i a b c d void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
next i a b c d void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
next i a b c d temp void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
next i a b c d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
first next i a b c d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
first next i b b c d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
first next i b b c d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
first next i b b c d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
first next i b c c d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
first next i b c c d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
first next i b c c d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
first next i b c d d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
first next i b c d d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
next first i b c d d temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
next first i b c d a temp a void do_cycle(I i, A a) { I next = i; a(next); if (next == i) return; UNDERLYING_TYPE(VALUE_TYPE(I)) temp; move_raw(deref(i), temp); I first = i; do { move_raw(deref(next), deref(first)); first = next; a(next); } while (next != i); move_raw(temp, deref(first));}
i b c d a (Destroy first, temp, next)
i b c d a Done!