add term stashing

rip joe :(
This commit is contained in:
Kyle Isom 2019-04-22 23:17:19 -07:00
parent 46c5fafa4f
commit 1d483e23ca
1 changed files with 13 additions and 1 deletions

View File

@ -6,7 +6,9 @@
perms/1,
kabs/1,
kfilter/2,
kclassify/1
kclassify/1,
stash_term/2,
retrieve_term/1
]).
for(Max, Max, F) ->
@ -61,3 +63,13 @@ kclassify(N) ->
true ->
low
end.
stash_term(Path, Term) ->
file:write_file(Path, erlang:term_to_binary(Term)).
retrieve_term(Path) ->
case file:read_file(Path) of
{ok, BinaryTerm} ->
erlang:binary_to_term(BinaryTerm);
{error, Reason} -> throw({read_file, Reason})
end.