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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:08:07+00:00 2026-05-15T19:08:07+00:00

Idle pondering from a Scala learner perhaps, but … in my tinkerings I’ve written

  • 0

Idle pondering from a Scala learner perhaps, but … in my tinkerings I’ve written the following:

( n.child.size > 0 ) && ( n.child.filter( ! _.isInstanceOf[Text] ).size == 0 )

(‘n’ is a scala.xml.Node, but that’s not important. Nor is the particular logic.)

Calling child() twice isn’t so good, so I was about to change it:

val list = n.child
( list.size > 0 ) && ( list.filter( ! _.isInstanceOf[Text] ).size == 0 )

But given how much I’ve come to much appreciate being able to filter() and map() and such without needing to declare intermediate variables, I found this immediately smelly. It’s so… so… so Java-ish! :p

Alas, digging through SO and Google and the ScalaDocs (especially Any and AnyRef) and The Book has turned up nothing appropriate. I was hoping perhaps for something like:

n.child{ list => ( list.size > 0 ) && ( list.filter( ! _.isInstanceOf[Text] ).size == 0 ) }

or even

n.child.with{ list => ... }

Does something like this exist? Or am I just getting caught up in a variable-less-ness fervour?

  • 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-15T19:08:08+00:00Added an answer on May 15, 2026 at 7:08 pm

    “with” is, of course, a reserved word in Scala, so let’s call it “let”, from the similar binding form in Lisp and Haskell. Turns out “let” is just a backwards way of writing function application.

    def let[A,B](param:A)(body: A=>B):B = body(param)
    
    let(n.child){list=> ...}
    

    If the bound variable is used only once, you could of course use the anonymous function form, but that defeats the purpose.

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

Sidebar

Related Questions

My python scripts run fine from IDLE, but when I try to run them
Why does IDLE handle one symbol correctly but not another? >>> e = '€'
I messed up my IDLE shortcut. What is the way to start IDLE from
I'd like to add IDLE-like functionality to C# WinForms application, but I don't quite
Just out of idle curiosity and Google didn't give me an answer, but what
I'm currently using IDLE, its decent, but I'd like to know if there're better
Im using IDLE on windows 7. When I run the following code uni =
How can i start the Python-IDLE from a python script in a way so
If I type the following into IDLE, it gives me the result of 'wordwordword':
I want to show a BalloonTip in the Application.Idle event of my program, but

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.