int rotate_a_b(t_stack *a, t_stack *b, int rev) { if (rev) { rotate_r(a); rotate_r(b); } else { rotate(a); rotate(b); } return (SUCCESS); }
int do_op(t_stack *a, t_stack *b, char *s) { t_opcode op; if ((op = get_op(s)) == NONE) return (FAILURE); op == SA ? swap(a) : (0); op == SB ? swap(b) : (0); op == SS ? swap_a_b(a, b) : (0); op == RA ? rotate(a) : (0); op == RB ? rotate(b) : (0); op == RR ? rotate_a_b(a, b, 0) : (0); op == RRA ? rotate_r(a) : (0); op == RRB ? rotate_r(b) : (0); op == RRR ? rotate_a_b(a, b, 1) : 0; if (op == PA && !empty(b)) push(a, pop(b)); if (op == PB && !empty(a)) push(b, pop(a)); handle_opts(a, b, s); return (SUCCESS); }
t_lst *add2(t_lst *lst_a, t_lst *lst_b, t_lst *tmp, int c) { while (lst_a->next != NULL) lst_a = lst_a->next; while (lst_a->content != c) { lst_a = tmp; lst_a = rotate_r(lst_a, lst_b, tmp, "rra "); while (lst_a->next != NULL) lst_a = lst_a->next; } return (lst_a); }