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

  1. what way implement this?
  2. 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: alt text

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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -