| #!/bin/bash | |
| ################ | |
| # Uncomment if you want the script to always use the scripts | |
| # directory as the folder to look through | |
| #REPOSITORIES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
| REPOSITORIES=`pwd` | |
| IFS=$'\n' |
| -module(assignment1). | |
| -export([perimeter/1, area/1, enclose/1, bits/1, directBits/1]). | |
| %%%ASSIGNEMENT ABOUT perimeter, area and enclose functions | |
| perimeter({'circle', {_X,_Y}, R}) -> (R+R)*math:pi(); | |
| perimeter({'rectangle', {_X,_Y}, H,W}) -> (H+W)*2; | |
| perimeter({'triangle', {_X,_Y}, A,B,C}) -> A+B+C. | |
| area({'circle', {_X,_Y}, R}) -> (R*R)*math:pi(); |
| -module(pattern_matching). | |
| -export([exclusiveOr/2,exclusiveOr2/2,exclusiveOr3/2, maxThree/3, howManyEquals/3]). | |
| exclusiveOr(X,Y) -> | |
| not(X==Y). | |
| exclusiveOr2(X,Y) -> | |
| (X=/=Y). | |
| exclusiveOr3(X,Y) when (X and Y) -> false; |
| #!/bin/bash | |
| if [[ $# -le 1 ]] ; then | |
| echo 'No plugins parameters provided. Please run the script with a plugin type and name. (e.g.: devices persistence)' | |
| exit 0 | |
| fi | |
| freedomoticHome=$(pwd) | |
| echo "Building freedomotic..." |
| Loading global plugins from /home/user/.sbt/0.13/plugins | |
| Loading project definition from /home/user/development/scala/scalagoon/myplugin/project | |
| Set current project to myplugin (in build file:/home/user/development/scala/scalagoon/myplugin/) | |
| [warn] Binary version (2.11) for dependency org.scala-lang#scala-library;2.11.8 | |
| [warn] in it.flatmap#myplugin;0.0.1 differs from Scala binary version in project (2.10). | |
| Wrote /home/user/development/scala/scalagoon/myplugin/target/scala-2.10/sbt-0.13/myplugin-0.0.1.pom | |
| :: delivering :: it.flatmap#myplugin;0.0.1 :: 0.0.1 :: integration :: Thu Nov 10 19:46:49 CET 2016 | |
| delivering ivy file to /home/user/development/scala/scalagoon/myplugin/target/scala-2.10/sbt-0.13/ivy-0.0.1.xml | |
| Packaging /home/user/development/scala/scalagoon/myplugin/target/scala-2.10/sbt-0.13/myplugin-0.0.1.jar ... | |
| Done packaging. |
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| box = 'ubuntu/trusty64' | |
| hostname = 'emberclibox' | |
| domain = 'example.com' | |
| ip = '192.168.42.42' | |
| ram = '512' | |
| $rootScript = <<SCRIPT |
| #!/bin/bash | |
| if [ ! -f ~/runonce ] #here the check is on the root home directory | |
| then | |
| echo ':::: setting up liquidprompt to vagrant machine ::::' | |
| echo "Installing liquidprompt..." | |
| cd /home/vagrant/ | |
| git clone https://github.com/nojhan/liquidprompt.git | |
| source liquidprompt/liquidprompt |
This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere… I hope to present the information you need without assuming anything.
Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!
One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.
Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x