Skip to content

Commit

Permalink
Unable to return map if goal is ground truth facts
Browse files Browse the repository at this point in the history
  • Loading branch information
fogfish committed Jan 16, 2019
1 parent 5a71805 commit 3f7ac61
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/datalog.erl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@ c_tuple(Source, [#goal{id = Goal, head = Head} | Datalog]) ->

c_map(Source, [#goal{id = Goal, head = Head} | Datalog]) ->
Lprogram = lists:foldl(fun(Horn, Acc) -> compile(Source, Horn, Acc) end, #{}, Datalog),
{_, _, Vars, _} = lists:keyfind(Goal, 2, Datalog),
Vars = case lists:keyfind(Goal, 2, Datalog) of
{_, _, X, _} ->
X;
#source{} ->
[<<$_, (typecast:s(X))/binary>> || X <- lists:seq(1, length(Head))]
end,
Fun = maps:get(Goal, Lprogram),
fun(Env) ->
stream:map(
Expand All @@ -179,7 +184,6 @@ c_map(Source, [#goal{id = Goal, head = Head} | Datalog]) ->
)
end.


compile(Source, #source{id = Id, head = Head}, Datalog) ->
Datalog#{Id => datalog_vm:stream(fun Source:stream/3, Id, Head)};

Expand Down

0 comments on commit 3f7ac61

Please sign in to comment.