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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:10:29+00:00 2026-05-24T17:10:29+00:00

I found myself using these 2 custom generators and thinking there’s got to be

  • 0

I found myself using these 2 custom generators and thinking “there’s got to be an itertools function or something that already does this! Didn’t find any though. Am I missing something? Thanks!

def gothru(iters):
  for i in iters:
    for j in i:
      yield j

def overnover(fn,startval):
  val = startval
  while True:
    val = fn(val)
    yield val

EDIT: i was later imagining how overnover could be used to generate the fibonacci sequence, and i realized that it would need to be generalized to allow the function to have more than one argument

def overnover(fn,*args):
  while True:
    args = fn(*args)
    return args

then you could do:

fibInfo = overnover(lambda x,y: (x+y, x), 1, 1)

-> (2,1) … (3, 2) … (5, 3) … (8, 5) …
and then:

fib = imap(lambda x:x[0], fibInfo)

-> 2 … 3 … 5 … 8 …

thanks guys!

  • 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-24T17:10:30+00:00Added an answer on May 24, 2026 at 5:10 pm

    The first one is chain.from_iterable.

    The closest thing to overnover is something like tabulate:

    def tabulate(function, start=0):
        "Return function(0), function(1), ..."
        return imap(function, count(start))
    

    which is a special case of your function where it outputs sequential numbers. count also takes a step, so you could generalize this to

    def tabulate(function, start=0, step=1):
        "Return function(0), function(0+step), ..."
        return imap(function, count(start, step))
    

    Here is a version of overnover that would let you send values into the sequence:

    def overnover(fn, val):
        while True:
            val = fn(val)
            val = (yield val) or val
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

These last weeks, I found myself using a lot of const everywhere. Not only
I am using ASP.Net 2.0. I found myself in an awkward situtation because I
Hopefully a simple question although one I have found impossible to answer myself using
I just found myself creating a class called InstructionBuilderFactoryMapFactory. That's 4 pattern suffixes on
I have found myself designing a language for fun that is a cross between
I've found myself evaluating both of these libs. Apart from what the GraphicsMagick comparison
Lately I found myself using jQuery and JavaScript a lot, often to do the
I'm creating a Jersey web service, and I've found myself using both of the
Now about 2 weeks into learning Ruby and Rails, I've found myself using the
I'm trying to make myself a GUI library using plain WinAPI. But I 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.