You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that the Array term type is congruous to the List (pairs, cons cells, etc) type used in classic microKanren implementations. However, the data pattern (how to construct/deconstruct) Arrays in JavaScript isn't congruous with List implementations; they're not cons cells. Consider the following implementation of pusho; intuitive structural composition doesn't work to unify an array and therefore extra information may need to be passed to unify so that we may represent subsets of an array as symbols.
constpusho=(arr: Term,item: Term,out: Term): Goal=>{if(typeofarr==="symbol"){// return unify([arr, Symbol.for("spread-left"), item], out);}if(Array.isArray(arr))returnunify([...arr,item],out);returnfail(`pusho :: rest term type (${typeofarr}) not supported`);}
The text was updated successfully, but these errors were encountered:
Term
s encompass the data type of values that can be used within the microKanren system. Here's what they are:Note that the
Array
term type is congruous to theList
(pairs, cons cells, etc) type used in classic microKanren implementations. However, the data pattern (how to construct/deconstruct)Array
s in JavaScript isn't congruous withList
implementations; they're not cons cells. Consider the following implementation ofpusho
; intuitive structural composition doesn't work to unify an array and therefore extra information may need to be passed tounify
so that we may represent subsets of an array as symbols.The text was updated successfully, but these errors were encountered: