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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:32:45+00:00 2026-05-26T15:32:45+00:00

I want to append 3 lists or more at once in a single expression.

  • 0

I want to append 3 lists or more at once in a single expression.

a ++ b ++ c

Will the ++ operator will be evaluated from left to right or right to left?

1. (a ++ b) ++ c
2. a ++ (b ++ c)

I would say option 2, because if ++ was a prefix function, we would write ++ a ++ b c which naturally leads to evaluating ++ b c first. I’m not sure if I’m correct.

But if it’s option 1, it seems to me that explicitely changing the order of evaluation from right to left is more efficient:

a ++ (b ++ c)

Here is why: a ++ b ++ c will first evaluate to ab ++ c in n steps (where n is the length of a and ab is of course the concatenation of a and b) and then to abc in n+m more steps (m being the length of b, thus n+m the is the length of ab), which makes a total of 2n+m steps. Whereas a ++ (b ++ c) will first evaluate to a ++ bc in m steps, and then to abc in n more steps, which is a total of n+m steps only.

I’m new to haskell and not sure about what I’m saying, I’d like some confirmation.

  • 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-26T15:32:46+00:00Added an answer on May 26, 2026 at 3:32 pm
    a ++ b ++ c
    

    is parsed as

    a ++ (b ++ c)
    

    for exactly the reasons you describe: had (++) been left-associative, then a ++ b ++ c would copy a twice. You can check this in GHCi with

    Prelude> :i (++)
    

    which will respond with

    infixr 5 ++
    

    where infixr means “infix, right-associative”.

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

Sidebar

Related Questions

I have a list of lists, I want to append more lists to it.
I would like to append append an item more than once. e.g listA =
I have an unordered list with elements and I want to append an item
I have a list like: list = [[1,2,3],[4,5,6],[7,8,9]] I want to append a number
I want to append some nodes to an xml document using Linq2XML. The file
I want to append a record in a TClientDataSet based on another record (in
I want to append a <br /> to a particular class. Using the :after
I want to .append to a div and pass the value on as html
I have a binary file to which I want to append a chunk of
In my application, I want to append cells to the current tableview and 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.