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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:20:12+00:00 2026-05-27T21:20:12+00:00

In the following generalized code: nat = [1..xmax] xmax = *insert arbitrary Integral value

  • 0

In the following generalized code:

nat = [1..xmax]
xmax = *insert arbitrary Integral value here*   

setA = [2*x | x <- nat]
setB = [3*x | x <- nat]

setC = [4*x | x <- nat]
setD = [5*x | x <- nat]

setOne = setA `f` setB
setTwo = setC `f` setD

setAll = setOne ++ setTwo

setAllSorted = quicksort setAll

(please note that ‘f’ stands for a function of type

f :: Integral a => [a] -> [a] -> [a] 

that is not simply ++)

how does Haskell handle attempting to print setAllSorted?

does it get the values for setA and setB, compute setOne and then only keep the values for setOne in memory (before computing everything else)?

Or does Haskell keep everything in memory until having gotten the value for setAllSorted?

If the latter is the case then how would I specify (using main, do functions and all that other IO stuff) that it do the former instead?

Can I tell the program in which order to compute and garbage collect? If so, how would I do that?

  • 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-27T21:20:13+00:00Added an answer on May 27, 2026 at 9:20 pm

    The head of setAllSorted is necessarily less-than-or-equal to every element in the tail. Therefore, in order to determine the head, all of setOne and setTwo must be computed. Furthermore, since all of the sets are constant applicative forms, I believe they will not be garbage collected after being computed. The numbers themselves will likely be shared between the sets, but the cons nodes that glue them together will likely not be (your luck with some will depend upon the definition of f).

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

Sidebar

Related Questions

I've got the following JAXB unmarshalling code which I'm trying to generalize. Here's what
Found the following in an Oracle-based application that we're migrating (generalized) : SELECT Table1.Category1,
Assuming that I have the following code: final Catalog catalog = createCatalog(); for (int
I have the following code. class person(object): def __init__(self, keys): for item in keys:
Given the following code: public class FooBar { public static volatile ConcurrentHashMap myConfigData =
I have the following C code: const BYTE* Items[3]; Items[0] = item1; Items[1] =
I have the following code which works well, but the problem is that after
I have written the following code: library(ggplot2) data <- structure(list(x = c(1L, 6L, 3L,
The following code is supposed to move UIElements in a canvas, when the mouse
I had the following code of bresenham's algorithm which represents adapted to Scala Java

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.