def remove_pointer(asker, object): result = updates.update(updates.remove_modifier(is_pointer()), object) result = updates.update(updates.remove_modifier(has_pointer()), object) result = updates.update( updates.apply_to( all_children(), lists.update_map(remove_pointer()) ), result ) return asker.reply(answer=result)
def add_pointer_to_bottom(asker, object): visible_children = asker.ask(fields.get_field(visible_children()), object).firm_answer if convert.check_hard(asker, lists.is_empty(), visible_children): return asker.reply(answer=updates.update(is_pointer_now(), object)) else: result = updates.update(has_pointer_now(), object) result = updates.update( updates.apply_to( fields.compose(visible_children(), lists.last_element()), add_pointer_to_bottom() ), result ) return asker.reply(answer=result)
def add_children_on_expanded(asker, old, new, bindings): children = [] for p in lists.iterator(asker, lists.from_dict(bindings)): k = asker.ask(fields.get_field(first(), p)).firm_answer v = asker.ask(fields.get_field(second(), p)).firm_answer prefix = strings.string_concat(k, T.from_str(": ")) new_node = node_from_term(asker, v) new_node = updates.update( updates.apply_to(headline(), strings.prepend_str(prefix)), new_node ) children.append(new_node) return asker.reply(answer=updates.update( fields.set_field(all_children(), T.from_list(children)), new ))