Use of ^^

65 views
Skip to first unread message

Jesse Johnson

unread,
Sep 29, 2016, 11:34:48 AM9/29/16
to scala-user
Hi,

I have searched the book, looked online, and searched the manual, and I cannot find the meaning of ^^ in the statement:

wholeNumber ^^ { s => SNum(s.toInt) }

It is probably something really simple that is driving me crazy. Any help?

Thanks,

Jesse

Rafael Trindade Chiappetta

unread,
Sep 29, 2016, 11:42:10 AM9/29/16
to Jesse Johnson, scala-user
I know that ^ is a binary XOR operator, but I have never used it.

https://www.tutorialspoint.com/scala/scala_operators.htm


=====
Rafael Trindade Chiappetta


--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rex Kerr

unread,
Sep 29, 2016, 11:43:34 AM9/29/16
to Jesse Johnson, scala-user
When you ask questions like this it is _really_ important to say what the context is, because any library can define its own ^^ operator.  Alternatively, you can search using symbolhound which indexes crazy stuff like this.

Anyway, it turns out that you are looking at Scala's parser combinator code.  ^^ basically means map--take your existing parser and tell it to apply some function to its contents (generating a new parser that does this mapping).

That it is called ^^ instead of map is one of about a million reasons you should always use FastParse instead of the old parser combinators.

  --Rex


--

Adriaan Moors

unread,
Sep 29, 2016, 11:45:06 AM9/29/16
to Rafael Trindade Chiappetta, Jesse Johnson, scala-user
Right, what Rex said -- methods can have symbolic names. This particular one is likely defined here: https://github.com/scala/scala-parser-combinators/blob/1.0.x/shared/src/main/scala/scala/util/parsing/combinator/Parsers.scala#L370

On Thu, Sep 29, 2016 at 8:41 AM Rafael Trindade Chiappetta <rafae...@gmail.com> wrote:
I know that ^ is a binary XOR operator, but I have never used it.

https://www.tutorialspoint.com/scala/scala_operators.htm


=====

Rafael Trindade Chiappetta

On Thu, Sep 29, 2016 at 11:46 AM, Jesse Johnson <jesse.ala...@gmail.com> wrote:
Hi,

I have searched the book, looked online, and searched the manual, and I cannot find the meaning of ^^ in the statement:

wholeNumber ^^ { s => SNum(s.toInt) }

It is probably something really simple that is driving me crazy. Any help?

Thanks,

Jesse

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.

Dennis Haupt

unread,
Sep 29, 2016, 12:27:09 PM9/29/16
to Adriaan Moors, Rafael Trindade Chiappetta, Jesse Johnson, scala-user
if i were you, i would have this code open in my ide and just use "jump to declaration"
 
Gesendet: Donnerstag, 29. September 2016 um 17:44 Uhr
Von: "Adriaan Moors" <adr...@lightbend.com>
An: "Rafael Trindade Chiappetta" <rafae...@gmail.com>, "Jesse Johnson" <jesse.ala...@gmail.com>
Cc: scala-user <scala...@googlegroups.com>
Betreff: Re: [scala-user] Use of ^^

Jesse Johnson

unread,
Sep 29, 2016, 12:49:57 PM9/29/16
to scala-user
Gentlemen,

Thank you for your extremely helpful answers to my question. I appreciate the assistance.

Thanks,

Jesse

Naftoli Gugenheim

unread,
Oct 9, 2016, 9:16:18 PM10/9/16
to Jesse Johnson, scala-user
Hi, I guess your actual question was answered but for the future, most internet search engines aren't helpful for symbols but there's one that is: symbolhound. If you search in symbolhound for "^^ scala" you get this page http://symbolhound.com/?q=%5E%5E+scala which has some helpful links.


Reply all
Reply to author
Forward
0 new messages