[Om3] homework, describing a definition for n-ary plus
Jan Willem Knopper
j.w.knopper at tue.nl
Thu Jun 5 17:47:02 CEST 2014
<!--
NOTATION: arith1.plus is <OMS cd='arith1' name='plus'/>
This is a example description of an n-ary plus, defined based on a
binary plus (for which I use homework2.plus2).
homework1.function_with_arguments describes an n-ary function which
can be defined by allowing access to the arguments in a single variable
(by an OMBIND). Several computer languages have a keyword or accessor to
get to an array of arguments (Javascript, GAP).
homework1.length returns the length of an argument sequence/list
homework1.first returns the first argument of an argument sequence/list
homework1.rest returns a new argument sequence/list containing all but
the first argument.
homework1.argument_sequence is implied (argument list)
-->
<--
real question
is the idea that I describe an n-ary function with a new cd good
enough for all applications ?
regardless of whether we need it for this definition it might be good
to have some new kind of apply function that calls a function with the
arguments in a list (list1.list ?).
will it be good enough to do this in a cd as well,
homework1.apply_with_arguments:
@(homework1.apply_with_arguments,arith1.plus,@(homework1.argument_sequence,1,2,3))
is it possible to do correct types for this, or will this run into
problems ?
Any other comments ?
-->
<DEFMP>
<OMS cd='arith1' name='plus'/>
<OMBIND>
<OMS cd='homework1' name='function_with_arguments'/>
<OMBVAR>
<OMV name='arguments'/>
</OMBVAR>
<OMA>
<OMA>
<OMS cd='prog1' name='if'/>
<!-- 0 arguments: 0 -->
<OMA>
<OMS cd='relation1' name='eq'/>
<OMA>
<OMS cd='homework1' name='length'/>
<OMV name='arguments'/>
</OMA>
<OMI>0</OMI>
</OMA>
<OMI>0</OMI>
<OMA>
<OMS cd='prog1' name='if'/>
<!-- 1 arguments: value -->
<OMA>
<OMS cd='relation1' name='eq'/>
<OMA>
<OMS cd='homework1' name='length'/>
<OMV name='arguments'/>
</OMA>
<OMI>1</OMI>
</OMA>
<OMA>
<OMS cd='homework1' name='first'/>
<OMV name='arguments'/>
</OMA>
<OMA>
<OMS cd='prog1' name='if'/>
<!-- 2 arguments: plus2 on first two arguments -->
<OMA>
<OMS cd='relation1' name='eq'/>
<OMA>
<OMS cd='homework1' name='length'/>
<OMV name='arguments'/>
</OMA>
<OMI>1</OMI>
</OMA>
<OMA>
<OMS cd='homework2' name='plus2'/>
<OMA>
<OMS cd='homework2' name='plus2'/>
<OMA>
<OMS cd='homework1' name='first'/>
<OMV name='arguments'/>
</OMA>
<OMA>
<OMS cd='homework1' name='first'/>
<OMA>
<OMS cd='homework1' name='rest'/>
<OMV name='arguments'/>
</OMA>
</OMA>
</OMA>
</OMA>
<OMA>
<OMS cd='prog1' name='if'/>
<!-- more than 2 arguments: recursive -->
<OMA>
<OMS cd='arith1' name='plus'/>
<OMA>
<OMS cd='homework2' name='plus2'/>
<OMA>
<OMS cd='homework1' name='first'/>
<OMV name='arguments'/>
</OMA>
<OMA>
<OMS cd='homework1' name='first'/>
<OMA>
<OMS cd='homework1' name='rest'/>
<OMV name='arguments'/>
</OMA>
</OMA>
</OMA>
<OMA>
<OMS cd='homework1' name='rest'/>
<OMA>
<OMS cd='homework1' name='rest'/>
<OMV name='arguments'/>
</OMA>
</OMA>
</OMA>
</OMA>
</OMA>
</OMA>
</OMA>
</OMA>
</OMBIND>
</DEFMP>
More information about the Om3
mailing list