:- module confusing_message. :- implementation. :- import_module int, list, string. :- pred nice_message(list(string)::out) is det. nice_message(Outcomes) :- construct_unique_outcomes(COutcomes), int.fold_down( (pred(I::in,Tail::in,[ Outcome | Tail]::out) is det :- read_outcome(COutcomes, I, Outcome) ), 0, 3, [], Outcomes). % destroy_unique_outcomes(COutcomes). :- pred confusing_message(list(string)::out) is det. confusing_message(Outcomes) :- construct_unique_outcomes(COutcomes), Outcomes = int.fold_down( (func(I::in,Tail::in) = ([ Outcome | Tail]::out) is det :- read_outcome(COutcomes, I, Outcome) ), 0, 3, []). % destroy_unique_outcomes(COutcomes). :- type c_outcomes. :- pragma foreign_type("C", c_outcomes, "void *", [stable, can_pass_as_mercury_type]). :- pred construct_unique_outcomes(c_outcomes::uo) is det. :- pragma foreign_proc(c, construct_unique_outcomes(Outcomes::uo), [promise_pure, will_not_call_mercury], " // undefined Outcomes == NULL; "). :- pred destroy_unique_outcomes(c_outcomes::di) is det. :- pragma foreign_proc(c, destroy_unique_outcomes(Outcomes::di), [promise_pure, will_not_call_mercury], " // undefined free(Outcomes); "). :- pred read_outcome(c_outcomes::ui, int::in, string::out) is det. :- pragma foreign_proc(c, read_outcome(Outcomes::ui, Idx::in, String::out), [promise_pure, will_not_call_mercury], " String = ""nothing""; Outcomes == NULL; Idx == 0; "). /* Outcomes = int.fold_down( temp_func(COutcomes), % (func(I::in,Tail::in) = (Tail::out) is det :- % [ Outcome - Prob | Tail] :- % c_get_outcome(COutcomes, I, Outcome, Prob) % ), 0, c_outcomes_size(COutcomes)-1, []), */