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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:50:45+00:00 2026-06-14T19:50:45+00:00

I have a function fromRange which takes a filter function and an interval and

  • 0

I have a function fromRange which takes a filter function and an interval and returns a set with all elements in the interval that satisfy the filter function.

I implemented it using list comprehension:

fromRange   :: (Integer->Bool) -> (Integer,Integer)  -> [Integer]
fromRange f (x,y) = [i | i<-[x..y], f i]

but it takes very long time with big list so I found the lazy evaluation concept but I do not know how exactly to implement it, any help??

  • 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-06-14T19:50:46+00:00Added an answer on June 14, 2026 at 7:50 pm

    Lazy evaluation is not supposed to be faster for large datasets, it only postpones the evaluation until the very moment when the value is needed. For example, if you type in your ghci:

    fromRange (< 50) (1, 1000000000)
    

    you’ll have to wait forever before it iterates through the whole list to filter it and print the result.

    On the other hand:

    take 10 $ fromRange (< 50) (1, 1000000000)
    

    will complete instantly, because it does not have to calculate the rest of the list.

    Note: take 100 will hang as well, since it won’t ever find enough entries.

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

Sidebar

Related Questions

I have function getMemory() which returns VARIANT (mfc). It is said that in ulVal
I have a function which accepts fromRange and ToRange of an Excel cell. basically
I have function that returns the index of a character GetCharFromPos(Pt: TPoint): Integer; now
I have function which takes in an parameter of a class called Triple, and
I have function in Javascript which works fine using prototype. The function is used
I have function that have been colled in stored procedure. The function returns a
I have function build_additional_docs which calls another function that do few actions, but first
I have function bar which I need to call. I'm new to using callbacks,
So I have a function which always returns a number from range <0;99> (i.e.
I have function which append div (help icon) after all element with .help class.

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.