Verbs take 1 or 2 arguments, always nouns.
Explicit 'operator' adverbs/conjunctions take 1 or 2 operands (noun or
verb) and produce a 'derived verb' that waits for its 1 or 2 noun
arguments. The derived verb can access the original operands as u/v
(or, better, as u./v.).
If the u operand to equivalent is a noun, you can write
equivalent =: 2 : 0
NB. Here x is the original left arg to equivalent (5)
NB. u. is call
NB. v. is fresh
NB. y is whatever call/fresh operate on
...
)
and call with 5 (call equivalent fresh) y
If the u operand to equivalent is a verb, you will have to combine some
of the operands into a single name using ` :
equivalent =: 2 : 0
'`call fresh' =: v NB. AR assignment
NB. u is 5
...
)
and call with (5 equivalent (call`fresh)) y
I note in passing that referring to a noun twice has no overhead.
Henry Rich
On 12/29/2019 10:43 AM, Raoul Schorer wrote:
Thank you for your answer, Henry.
The output is not obvious from input, since it is the result of a chain of
several closures and I doubt anyone would want to take the time to dissect
the whole thing.
However, everything works as expected and my problem is just how to provide
better syntax. In short:
I have right now:
5 equivalent (call empty_state) (fresh empty_state)
which syntactically amounts to the following, where "equivalent" is a
conjunction:
u equivalent (monadic_verb_a y) (monadic_verb_b y)
I would like a semantically identical sentence, but avoiding the repetition
of y. Is that possible?
Raoul
On Sun, Dec 29, 2019 at 3:15 AM Henry Rich <henryhr...@gmail.com> wrote:
I would like to help, but I don't get what is called for. Maybe there
are Scheme users who will pipe up.
If not, can you describe what the desired input and output are?
Henry Rich
On 12/28/2019 8:51 PM, Raoul Schorer wrote:
Hi,
I am trying to implement minikanren <http://www.minikanren.org> in J. I
have it almost working, but I am stuck in the last part of the core
implementation
<https://github.com/jasonhemann/microKanren/blob/master/microKanren.scm>.
I
do not understand how to write "call/fresh" from the scheme code:
In J, where "empty_state" is a list of 2 boxes emulating "s/c":
(call empty_state) (equivalent 5) (fresh empty_state)
which as a first step evaluates to:
(1$0) (equivalent 5) ('',.@;1)
In the above working code, "empty_state" is repeated, and that is what I
want to avoid. "equivalent" is a conjunction, and "call" and "fresh" are
both monadic verbs applied to the noun "empty_state". In the scheme
version
"call" and "fresh" are united in "call/fresh", but this would require me
to
pass the "equivalent" conjunction as argument to "call/fresh".
Can you help me write the scheme "call/fresh" equivalent, please?
my code is at https://github.com/Rscho314/new_kanren
Thanks,
Raoul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm