background preloader

S-99: Ninety-Nine Scala Problems

S-99: Ninety-Nine Scala Problems
These are an adaptation of the Ninety-Nine Prolog Problems written by Werner Hett at the Berne University of Applied Sciences in Berne, Switzerland. I (Phil Gold) have altered them to be more amenable to programming in Scala. Feedback is appreciated, particularly on anything marked TODO. The problems have different levels of difficulty. Those marked with a single asterisk (*) are easy. If you have successfully solved the preceeding problems you should be able to solve them within a few (say 15) minutes. Your goal should be to find the most elegant solution of the given problems. Solutions are available by clicking on the link at the beginning of the problem description. [I don't have example solutions to all of the problems yet. Working with lists In Scala, lists are objects of type List[A], where A can be any type. The solutions to the problems in this section will be in objects named after the problems (P01, P02, etc.). In many cases, there's more than one reasonable approach. Example:

Related:  Scala

Real-World Scala: Dependency Injection (DI) ← Posted: 2008-10-06 In this second post in the Real-World Scala series I am going to discuss how to implement/achieve Depenency Injection (DI) in Scala. Scala is a very rich and deep language that gives you several ways of doing DI solely based on language constructs, but nothing prevents you from using existing Java DI frameworks, if that is preferred. Using the Cake Pattern The current strategy we are using is based on the so-called Cake Pattern.

Setup - simple-build-tool - A build tool for Scala Trying SBT (Simple Build Tool) for compiling a simple (one file, perhaps two) Scala application with some dependencies (Apache Pivot) on Windows as specifying all the jars on the command line quickly becomes annoying... (I try to convert the tutorial files to Scala). Following the instructions here I have put the jar file in C:\Java\\misc and the sbt.cmd file in C:\Java\\bin Content of the latter: @echo offjava -Xmx512M -jar C:\Java\\misc\sbt-launch-0.7.4.jar %*

Roundup: Scala for Java Refugees 13 Feb 2008 To be honest, I’m somewhat kicking myself for writing this post. As I’ve said many times: roundup posts are for people who are too lazy to write real content. I can’t tell you how many blogs I’ve come across which have a roundup-to-post ratio of easily 3:1. You know it’s a bad sign when sites start having roundups of their roundups… Meta-roundups aside, I decided (after much deliberation) that a single post linking to all six parts of the series would be useful to one or two people. Java EE 6 and Scala » Source Allies Blog Last weekend while pondering the question “Is Scala ready for the enterprise?” I decided to write a simple Java EE 6 app entirely in Scala, without using any Java. I had three main reasons for doing this: one was just to see how easy/difficult it would be to write everything in Scala (it was easy). Another was to document the process for others journeying down the same road (the entire project is on github). Finally, I wanted to identify advantages of using Scala instead of Java that are specific to Java EE apps (I found several). Background

Effective Scala Table of Contents Other languages 日本語Русский简体中文 » Quick starting Scalatra or In which I discover Scalatra and sbt Everything's Beta Over the weekend, I was researching various frameworks for implementing a REST API. Although I had already started the implementation using Tornado, I wanted to see what else was out there. And am I glad I looked. I discovered Scalatra which seems to be exactly what I was looking for; a lightweight, sinatra-esque way to map URLs to actions that easily lends itself to testing. I especially like the uber-readable way the tests are written. Who wouldn’t want to write tests like this?

10 Scala One Liners to Impress Your Friends Register These Currently Available Domains Today Search for your ideal .CO Web Address Get it now before it's gone! Close Notify me when the auction is scheduled for Thank you for inquiring about this premium domain. scala.Option Cheat Sheet λ Tony's blog λ The weblog of Tony Morris Many people who are coming in to Scala first encounter the Option type, which may be thought of (among other things) as a type-safe null. They also encounter pattern matching as both a new and (relatively) powerful concept, but also one that is easy to understand. Hammurabi - A Scala Rule Engine We Recommend These Resources One of the most common reasons why software projects fail, or suffer unbearable delays, is the misunderstandings between the analysts who define the business rules of the domain for which the software is going to be written and the developers who have to code these rules. The latter write those rules in a language that is completely obscure for the first ones. In this way the business analysts don't have a chance to read, understand and validate what the programmers developed and then they can only empirically test the final software behavior, hardly covering all the possible corner cases and often recognizing mistakes only when it is too late. What Hammurabi is Hammurabi is a rule engine written in Scala that tries to leverage the features of this language making it particularly suitable to implement extremely readable internal Domain Specific Languages.

OSI: Office of Secret Intelligence Hi all, back again with the second part of the play scala+slick+postgres adventure. In part 1, I touched on some of the hurdles I needed to overcome in order to get things up and running. In this article, I'd like to show you how to set up a quick and snappy testing environment. For starters, we will want a separate test database for postgres. For local tests, just manually create the database and user, and grant that user privileges to create tables, etc. on that database:

Scala: The Static Language that Feels Dynamic Computing ThoughtsScala: The Static Language that Feels Dynamicby Bruce EckelJune 12, 2011 Summary The highest complement you can deliver in the Python world is to say that something is "Pythonic" -- that it feels and fits into the Python way of thinking. I never imagined that a static language could feel this way, but Scala does -- and possibly even better. I'm actually glad I waited this long before beginning to learn the language, because they've sorted out a lot of issues in the meantime. In fact, several versions of the language have made breaking changes with previous versions, requiring code rewrites. Some people have found this shocking; an indication that the language is "immature" and "not ready for the enterprise."

Implement your own Scala collection In Scala there are two families of collections: mutable and immutable ones. When you operate on a mutable collection, you change it in place, as a side effect. On the other hand, an immutable collection doesn't change but rather returns a new collection with the update you performed. Right now, the Scala library provides an immutable TreeSet but not its mutable counterpart. Let's see how to integrate our own. Preliminary choices