wolfram mathematica - Custom Notation question -
i need extract restrict value lists sublists, ie if vals
gives values of vars={x1,x2,x3,x4}
, , need values of svars={x2,x4}
restrict[list,vars,svars]
where
restrict[vars_, svars_, vals_] := extract[vals, flatten[position[vars, #] & /@ svars, 1]]
i'd improve code readability, perhaps defining following custom notation restrict[vars,svars,vals]
http://yaroslavvb.com/upload/custom-notation.png
my questions are
- what way implement this?
- is idea altogether?
good notations can useful - i'm not sure particular 1 needed...
that said, notation
package makes pretty easy. there many hidden boxes when use notation palette, i'll use screenshot:
you can see underlying notationmake*
downvalues construct using action -> printnotationrules
option. in[4] in screenshot generates
notationmakeexpression[ subscriptbox[vals_, rowbox[{vars_, "|", svars_}]], standardform] := makeexpression[ rowbox[{"restrict", "[", rowbox[{vars, ",", svars, ",", vals}], "]"}], standardform] notationmakeboxes[subscript[vals_, vars_ | svars_], standardform] := subscriptbox[makeboxes[vals, standardform], rowbox[{parenthesize[vars, standardform, alternatives], "|", parenthesize[svars, standardform, alternatives]}]]
Comments
Post a Comment