and.then / or.else: the right side is worked out only when the left has not already decided — "A, and then (only if A held) B", "A, or else (only if A failed) B".
and_then_or_else.zg
# `and.then` / `or.else` (owner, 2026-09-25): the right side is worked out only when the# left has not already decided — "A, and then (only if A held) B", "A, or else (only if# A failed) B". Plain `and` / `or` always work out both (examples/and_runs_both.zg).fnloud['name':str.utf8,'answer':bool]->bool{std::print.useful["checked ",'name',newln];return'answer';}MAIN{let'xs':=[3,5,8];let'i':uint64=7;# 'i' is past the end, so the list is never readif'i'at_mostlist.length[lend'xs']and.then'xs'[pos'i']equal_to5{std::print.useful["found",newln];}let'n':int32=0;if'n'equal_to0or.else100div.floor'n'<2{std::print.useful["small or nothing",newln];}let'a':=loud["first",false]and.thenloud["second",true];let'b':=loud["third",true]or.elseloud["fourth",true];let'c':=loud["fifth",true]and.thenloud["sixth",false];std::print.useful['a'," ",'b'," ",'c',newln];}
Output
small or nothing
checked first
checked third
checked fifth
checked sixth
false true false