M2
M2 copied to clipboard
Extend notation for Function_Thing
Currently if f = (x,y) -> x+y then f_i is essentially y -> i+y:
Function _ Thing := Function => (f,x) -> y -> f splice (x,y)
I suggest we define some sort of simple notation to define:
f(i, _) == y -> i+y
f(_, j) == x -> x+j
It doesn't have to be this exact notation or necessarily involve _, but ideally something simple and clear that we're leaving an input blank and producing a function.
This is helpful for instance in defining a functor F = Hom(M, _).
Roughly speaking, I think the implementation would involve:
- when parsing a comma-separated sequence, if
_is seen, produce a special type of code, sayInputSequence, - define
Function InputSequenceto return a new function.
Another, probably much easier route is to define Function _ Sequence and allow f_(i, null) but that might cause confusion (e.g. what if the first input of f is supposed to be a sequence? or that one of the inputs is really supposed to be null?)