This morning I was curious about how Scala curried functions and partially-applied functions are really compiled at a bytecode level.
Prior to that, I wrote this post that Higher order functions are the Haskell experience — which is also implicitly about curried functions — and it got me thinking about Scala, in particular why we might use one function syntax versus another, i.e., why would I use this syntax:
(this space left blank for the ToC over there --> )
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 18.2, “How to compile, run, and package a Scala project with SBT.”Back to top
You want to use SBT to compile and run a Scala project, and package the project as a JAR file.Back to top
Create a directory layout to match what SBT expects, then run
sbt compile to compile your project,
sbt run to run your project, and
sbt package to package your project as a JAR file.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a short recipe, Recipe 14.13, “How to make your Scala shell scripts run faster by pre-compiling them.”
You love using Scala as a scripting language, but you’d like to eliminate the lag time in starting up a script.
-savecompiled argument of the Scala interpreter to save a compiled version of your script.
A basic Scala script like this:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a short recipe, Recipe 14.9, “How to compile your Scala code faster with the 'fsc' command-line compiler.”
You’re making changes to a project and recompiling it with
scalac, and you’d like to reduce the compile time.
fsc command instead of
scalac to compile your code:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.5, “How to compile Scala code with 'scalac' and run it with 'scala'.”
Though you normally use the Simple Build Tool (SBT) to build Scala applications, you may want to use more basic tools to compile and run small test programs, in the same way you might use
java with small Java applications.
It's been a while since I've seen a problem related to using different versions of Scala, but I just ran into it now.
I had the common Scala SBT commands in the notes for my project named SARAH, and thought I'd list them here to make them easier to find:
I was just reading the Scala man page, looking for something else, when I ran across this tip on how to speed up the execution of Scala shell scripts, using the savecompiled flag of the
Summary: Java regular expressions in Java 1.4, featuring regex expressions and pattern matching, using the new Java Pattern and Matcher classes.
The following Java example offers an introduction to regular expressions in Java 1.4. In this code we're creating a regular expression that can search for a date. Specifically, that date must be in a format of two digits, followed by a hyphen, followed by two digits, followed by a hyphen, followed by four digits.
This date pattern is created in this line of code: