From 25bcfda65c0cce2dd62a5168ae42b44b7c154305 Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Sat, 11 Oct 2025 06:55:16 -0600 Subject: [PATCH] sf <-> tt logic seems done --- src/wfc_sftt.erl | 17 +++++++++++++++++ src/{wfc_tts.erl => wfc_ttfuns.erl} | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) rename src/{wfc_tts.erl => wfc_ttfuns.erl} (98%) diff --git a/src/wfc_sftt.erl b/src/wfc_sftt.erl index fe6a82b..9f8fddf 100644 --- a/src/wfc_sftt.erl +++ b/src/wfc_sftt.erl @@ -7,6 +7,8 @@ ]). -export([ + ttfun_to_tt/1, + ttfun_to_sf/1, arity/1, tt/1, sf/1, sf_to_tt/1, tt_to_sf/1, @@ -19,6 +21,21 @@ -opaque sf() :: {sf, wfc_bm:bm()}. -opaque tt() :: {tt, wfc_bm:bm()}. +-spec ttfun_to_tt(fun()) -> tt(). + +ttfun_to_tt(Fun) -> + {arity, Arity} = erlang:fun_info(Fun, arity), + Argses = bfls(Arity), + OutputCol = [erlang:apply(Fun, Args) || Args <- Argses], + {tt, wfc_bm:col(OutputCol)}. + + +-spec ttfun_to_sf(fun()) -> sf(). + +ttfun_to_sf(Fun) -> + tt_to_sf(ttfun_to_tt(Fun)). + + -spec arity(sf() | tt()) -> pos_integer(). arity({sf, BM}) -> matrix_arity(BM); diff --git a/src/wfc_tts.erl b/src/wfc_ttfuns.erl similarity index 98% rename from src/wfc_tts.erl rename to src/wfc_ttfuns.erl index 38dcd2d..0244420 100644 --- a/src/wfc_tts.erl +++ b/src/wfc_ttfuns.erl @@ -1,6 +1,6 @@ % @doc % library of truth tables --module(wfc_tts). +-module(wfc_ttfuns). -export_type([ bit/0,