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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:07:05+00:00 2026-05-17T22:07:05+00:00

All, I have confuse below may need your help suppose I have a row

  • 0

All,

I have confuse below may need your help

suppose I have a row based variable length data matrix

93  77  96  85
50  69  54  16
39  91  59  38
64  30  18  50
43  9   74  94
44  87  95  89
... 

I want to generate result data via above source with different generating algorithms while the different range selection algorithms, take below code for example

lsrc = [# above data]

def rangesel_001(lsrc):
    tmp = []
    for i in len(lsrc):
       if i % 2 = 0:
          tmp.append(lsrc[i])
    return tmp

def algo_001(lsrc):
    tmp = []
        for i in len(lsrc):
            tmp.append([x+1 for x in lsrc[i]]) 
    return tmp

So the data I want is:

dscl = algo_001(rangesel_001(lsrc))

Here comes is my questions:

1. suppose I have an extendable “rangesel” set and the “algo” is also extendable looks like this

rangesel_001()     algo_001()
rangesel_002()     algo_002()
rangesel_003()     algo_003()
…                    ...

I want to mix them, then invoke them in-a-go to get all the result what I want

rangesel_001 + algo_001
rangesel_001 + algo_002
rangesel_001 + algo_003

rangesel_002 + algo_001
rangesel_002 + algo_002
rangesel_002 + algo_003
...

is there a way easy to manager those function names then combine them to execute?

2. you may noticed the different part in “rangesel”s and “algo”s algorithm is snippet here:

if i % 2 = 0:
 and
[x+1 for x in lsrc[i]]

It there a way to exact those common part out from function definitions and I can just give somekind a list:

if i % 2 = 0   rangesel_001
if i % 3 = 0   rangesel_002
if i % 4 = 0   rangesel_003
 and
[x+1 for x in lsrc[i]] algo_001
[x/2 for x in lsrc[i]] algo_002

then I can get all the “rangeset” functions and “algo” sets?

3. maybe later I need this:

dscl = algo_001(rangesel_001(                             \
                             algo_002(rangesel_002(lsrc)) \  
                            ))

so, is there a painfulless way I can chain those “rangesel_002 + algo_001” combinations?
for example: suppose I already have the full combinations

rangesel_001 + algo_001
rangesel_001 + algo_002
rangesel_001 + algo_003

rangesel_002 + algo_001
rangesel_002 + algo_002
rangesel_002 + algo_003

now I want to pick random 3 to chain them and invoke to get result list?

dscl = random_pick(3, combination_list, lsrc)

Thanks!

  • 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-17T22:07:06+00:00Added an answer on May 17, 2026 at 10:07 pm

    For your first question, you can define a function composition operation like this:

    def compose(f, g):
        return lambda *x: f(g(*x))
    

    Then, you can:

    ra = compose(rangeset_001, algo_001)
    ra(lsrc)
    

    If you make lists of functions like this:

    rangesets = [rangeset_001, rangeset_002, rangeset_003]
    

    then you can iterate:

    for r in rangesets:
        ra = compose(r, algo_001)
        ra(lsrc)
    

    Expansion of this idea to the algo_xxx functions is also possible.

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

Sidebar

Related Questions

Another cry for help about this warning. First of all I have looked at
I have a signup page and basically I need data inserted into 4 tables.
I have about 8 entities that all have a one to one relationship with
I have a situation where all my selectors all have the same ancestor element
I have three classes that all have a static function called 'create'. I would
I have 50 newsletters which all have different email accouts, hex colour codes and
I have an NSMenu (belonging to an NSPopUpButton ) where the NSMenuItem all have
I have a database with Points of Interest that all have an address. I
I have a form[method=get] which has a number of checkboxes all have the same
i have hundreds of [mostly different] files in many different directories that all have

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.