@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
@prefix func: <http://www.w3.org/2007/rif-builtin-function#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>.
@prefix seq: <https://eyereasoner.github.io/eye/reasoning/seq#>.

{() seq:punctuate ()} <= true.
{?A seq:punctuate ?B} <= {
    ?B e:firstRest (?C ?D).
    (?A) func:reverse ?E.
    (?F ?G) list:append ?E.
    ?G seq:check true.
    true log:callWithCut true.
    ?G seq:format ?C.
    (?F) func:reverse ?H.
    ?H seq:punctuate ?D.
}.

{(?A) seq:check true} <= true.
{?A seq:check true} <= {
    ?A e:firstRest (?B ?C).
    ?C e:firstRest (?D ?E).
    (?D 1) math:sum ?B.
    ?C seq:check true.
}.

{(?A) seq:format (?A ", ")} <= true.
{?A seq:format (?B "-" ?C ", ")} <= {
    ?A e:firstRest (?C ?D).
    ?D list:last ?B.
}.
