walk   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/mpi/random-walk.xtm

Implementation

(bind-func walk
  (lambda (walker:Walker* region:DomainRegion* domain_size outgoing_walkers)
    (let ((location (tref walker 0))
          (steps_remaining (tref walker 1))
          (region_start (tref region 0))
          (region_size (tref region 1)))
      (if (< (+ location steps_remaining)
             (+ region_start region_size))
          ;; walk ends in this domain
          (begin (tfill! walker (+ location steps_remaining) 0) void)
          (begin
            (tfill! walker
                    (if (> (+ location steps_remaining) domain_size)
                        0 ;; off the end of the world! need to wrap
                        (+ region_start region_size)) ;; beginning of next region
                    (% (+ location steps_remaining) region_size))
            (add_walker outgoing_walkers walker))))))


Back to Index

Similar Entries

  • BTree_walk_inorder    xtlang
  • BTree_walk_postorder    xtlang
  • BTree_walk_preorder    xtlang
  • Widget_walk_inorder    xtlang
  • Widget_walk_postorder    xtlang
  • Widget_walk_preorder    xtlang
  • add_walker    xtlang
  • clear_walker_array    xtlang
  • create_walker_array    xtlang
  • initialize_walkers    xtlang
  • print_walker    xtlang
  • print_walker_array    xtlang
  • receive_incoming_walkers    xtlang
  • send_outgoing_walkers    xtlang
  • walker_at_index    xtlang