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

  • Home
  • SEARCH
  • 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 799067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:04:06+00:00 2026-05-14T23:04:06+00:00

I’m currently learning the fascinating J programming language, but one thing I have not

  • 0

I’m currently learning the fascinating J programming language, but one thing I have not been able to figure out is how to filter a list.

Suppose I have the arbitrary list 3 2 2 7 7 2 9 and I want to remove the 2s but leave everything else unchanged, i.e., my result would be 3 7 7 9. How on earth do I do this?

  • 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-14T23:04:07+00:00Added an answer on May 14, 2026 at 11:04 pm

    The short answer

       2 (~: # ]) 3 2 2 7 7 2 9
    3 7 7 9
    

    The long answer

    I have the answer for you, but before you should get familiar with some details. Here we go.

    Monads, dyads

    There are two types of verbs in J: monads and dyads. The former accept only one parameter, the latter accept two parameters.

    For example passing a sole argument to a monadic verb #, called tally, counts the number of elements in the list:

       # 3 2 2 7 7 2 9
    7
    

    A verb #, which accepts two arguments (left and right), is called copy, it is dyadic and is used to copy elements from the right list as many times as specified by the respective elements in the left list (there may be a sole element in the list also):

       0 0 0 3 0 0 0 # 3 2 2 7 7 2 9
    7 7 7
    

    Fork

    There’s a notion of fork in J, which is a series of 3 verbs applied to their arguments, dyadically or monadically.

    Here’s the diagram of a kind of fork I used in the first snippet:

     x (F G H) y
    
          G
        /   \
       F     H
      / \   / \
     x   y x   y
    

    It describes the order in which verbs are applied to their arguments. Thus these applications occur:

       2 ~: 3 2 2 7 7 2 9
    1 0 0 1 1 0 1
    

    The ~: (not equal) is dyadic in this example and results in a list of boolean values which are true when an argument doesn’t equal 2. This was the F application according to diagram.

    The next application is H:

       2 ] 3 2 2 7 7 2 9
    3 2 2 7 7 2 9
    

    ] (identity) can be a monad or a dyad, but it always returns the right argument passed to a verb (there’s an opposite verb, [ which returns.. Yes, the left argument! 🙂

    So far, so good. F and H after application returned these values accordingly:

    1 0 0 1 1 0 1
    3 2 2 7 7 2 9
    

    The only step to perform is the G verb application.

    As I noted earlier, the verb #, which is dyadic (accepts two arguments), allows us to duplicate the items from the right argument as many times as specified in the respective positions in the left argument. Hence:

       1 0 0 1 1 0 1 # 3 2 2 7 7 2 9
    3 7 7 9
    

    We’ve just got the list filtered out of 2s.

    Reference

    Slightly different kind of fork, hook and other primitves (including abovementioned ones) are described in these two documents:

    • A Brief J Reference (175 KiB)
    • Easy-J. An Introduction to the World’s most Remarkable Programming Language (302 KiB)

    Other useful sources of information are the Jsoftware site with their wiki and a few mail list archives in internets.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.