1 / 18

Animation of Stepanov’s do_cycle function, from Notes on Programming, Lecture 17

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.

fmartin
Télécharger la présentation

Animation of Stepanov’s do_cycle function, from Notes on Programming, Lecture 17

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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));}

  2. 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));}

  3. 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));}

  4. 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));}

  5. 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));}

  6. 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));}

  7. 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));}

  8. 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));}

  9. 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));}

  10. 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));}

  11. 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));}

  12. 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));}

  13. 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));}

  14. 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));}

  15. 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));}

  16. 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));}

  17. i b c d a (Destroy first, temp, next)

  18. i b c d a Done!

More Related