Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3399820
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:49:03+00:00 2026-05-18T04:49:03+00:00

I often need to extract to restrict value lists to sublists, ie if vals

  • 0

I often need to extract to restrict value lists to sublists, ie if vals gives values of vars={x1,x2,x3,x4}, and I need values of svars={x2,x4} I do restrict[list,vars,svars] where

restrict[vars_, svars_, vals_] := 
 Extract[vals, Flatten[Position[vars, #] & /@ svars, 1]]

I’d like to improve code readability, perhaps by defining following custom notation for restrict[vars,svars,vals]


(source: yaroslavvb.com)

My questions are

  1. What is a good way to implement this?
  2. Is this a good idea altogether?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:49:04+00:00Added an answer on May 18, 2026 at 4:49 am

    Good notations can be very useful – but I’m not sure that this particular one is needed…

    That said, the Notation package makes this pretty easy. As there are many hidden boxes when you use the Notation palette, I’ll use a screenshot: alt text

    You can see the underlying NotationMake* downvalues construct by using the Action -> PrintNotationRules option. In[4] in the 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]}]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often need to list items with various-sized images on the left and text
Here at work, we often need to find a string from the list of
I often need to assign a variable, if the source value is set. So
I often need to match a tuple of values that should have the same
I need to store 5 boolean values in 1 table. Each value could be
I often need to remove lists of columns from a data.frame. I usually do
While developing ASP.NET applications I often need to parse a boolean value given in
I often need to run reduce (also called foldl / foldr, depending on your
I often need to design a dialog in Delphi/C++Builder that allows various properties of
I often need to display information based on or influenced by a user's actual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.