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 5967871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:00:25+00:00 2026-05-22T20:00:25+00:00

See below matrix data: A B C D E F G 1 89 92

  • 0

See below matrix data:

    A   B   C   D   E   F   G
1   89  92  18  7   90  35  60
2   62  60  90  91  38  30  50
3   59  91  98  81  67  88  70
4   20  28  31  9   91  6   18
5   80  27  66  1   33  91  18
6   82  30  47  8   39  22  32
7   14  11  70  39  18  10  56
8   98  95  84  47  28  62  99

I need to define “rule” function can return “true” or “false” for below asserts string for each row data:

A=B and B=C
A>C
B>C
C>D and D<E or D>F
A+B<30
A+B<=30                # this may using "A+B<30 or A+B=30" as alternative
str(A) march regex"[2-5][0-2]" 
myfoo(A) > 100 
A in myfoo(B)
A not_in $listname
A in $listname

Take “A=B and B=C” for example: If I pass row 1 into this rule, I want the rule return false because it is not right in this case.

My questions are:

  1. How can I define a DSL parser to translater those “rules string” into a workable lambda function, then I can invoke this lambda with data row as parameter to return the assert result?

  2. I noticed the module operation has a lot of math functions I can reuse to define the rule, can I create a “mapper” for those keywords for DSL parser use?
    It may looks like:

    keywords = {“+”: operation.add(),
    “/”: operation.div(),
    “and”: my_and_define()
    }

  3. if above 2 are possible, how can I process the “A in $listname” in the lambda and in the mapper?

Thanks for your help.

Rgs,

KC

  • 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-22T20:00:25+00:00Added an answer on May 22, 2026 at 8:00 pm

    Like this.

    class Rule( object ):
        def __init__( self, text ):
            self.text= text
        def test( self, A, B, C, D, E, F, G ):
            return eval( self.text )
    
    r1= Rule( "A==B" )
    r2= Rule( "A==B and B==C" )
    r3= Rule( "A in {listname!s}".format( listname=someList ) )
    

    etc.

    >>> r1.test( 89,  92,  18,  7,   90,  35, 60 )
    False
    

    Edit.

    • str(A) march regex”[2-5][0-2]”
    • myfoo(A) > 100
    • A is in myfoo(B)

    These are all trivial Python code. I’m not sure why the comment is even included as being interesting or difficult.

    r4= Rule( "re.match( r'[2-5][0-2]', str(A) )" )
    r5= Rule( "myfoo(A) > 100" )
    r6= Rule( "A in myfoo(B)" )
    

    There’s a trick to this. The trick is to write the Python code; and then enclose the code in quotes. Any Python code is legal.

    If the Python aspect of these rules is confusion, a Python tutorial may be helpful.

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

Sidebar

Related Questions

As you can see below, in the constructor I'm instantiating a validation object so
I have one text input and one button (see below). How can I use
I have a table defined (see code snippet below). How can I add a
I need to read a large (2000x2000) matrix of binary data from a file
I have XML (see below). I need to insert the records in this XML
I have a stored procedure (see below) which inserts data into a physical table
I have a list like df_all (see below). A = matrix( ceiling(10*runif(8)), nrow=4) colnames(A)
How do I implement this method (see below)? I'm new to Objective-C and I'm
I have a very large file that looks like this (see below). I have
I'm writing an editor for large archive files (see below) of 4GB+, in native&managed

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.