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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:17:09+00:00 2026-05-25T10:17:09+00:00

Can someone provide some examples for how /: :\ and /:\ Actually get used?

  • 0

Can someone provide some examples for how

/: :\ and /:\

Actually get used? I assume they’re shortcuts to the reduce / fold methods, but there’s no examples on how they actually get used in the Scala docs, and they’re impossible to google / search for on StackOverflow.

  • 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-25T10:17:09+00:00Added an answer on May 25, 2026 at 10:17 am

    /: is a synonym for foldLeft and :\ for foldRight.

    But remember that : makes /: apply to the object to the right of it.

    Assuming you know that (_ * _) is an anonymous function that’s equivalent to (a, b) => a * b, and the signature of foldLeft and foldRight are

    def foldLeft  [B] (z: B)(f: (B, A) ⇒ B): B 
    def foldRight [B] (z: B)(f: (A, B) ⇒ B): B 
    

    i.e. they’re curried functions taking a start value and a function combining the start value / accumulator with an item from the list, some examples are:

    List(1,2,3).foldLeft(1)(_*_)
    

    which is the same as

    (1 /: List(1,2,3))(_*_)
    

    And

    List(1,2,3).foldRight(1)(_*_)
    

    in infix notation is

    (List(1,2,3) foldRight 1)(_*_)
    

    which is the same as

    (List(1,2,3) :\ 1)(_*_)
    

    Add your own collections and functions and enjoy!

    The thing to remember with the short (/: and :\) notations is that, because you’re using the infix notations you need to put parentheses around the first part in order for it to pick up the second argument list properly. Also, remember that the functions for foldLeft and foldRight are the opposite way round, but it makes sense if you’re visualising the fold in your head.

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

Sidebar

Related Questions

Can someone point me out to some C# code examples or provide some code,
Hey Guys! Me again! Can someone provide me with some example code of how
Can someone provide some light on how to do this? I can do this
Can someone provide a simple explanation of methods vs. functions in OOP context?
I've seen some scripts examples over SO, but none of them seems to provide
Hope someone can provide some guidance - i've been using android sax parser with
Can someone please provide some advise on how to go about creating custom validation
Can someone provide a regular expression for parsing name/value pairs from a string? The
Can someone provide the download link for SQL Server Reports add-in for Visual Studio
Can someone provide an example of how to load a .svg file and display

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.