This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Posix.Process | |
import System.Posix.Types | |
import System.Directory | |
callSystem :: String -> [String] -> IO () | |
callSystem "cd" args = setCurrentDirectory $ head args | |
builtinCommands :: [String] | |
builtinCommands = ["cd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f1 :: Int -> Int -> Int | |
f1 x y = let f2 :: Int -> Int -> Int | |
f2 x z = x + y + z | |
in let f2 :: Int -> Int -> Int | |
f2 y z = if y == 10 then x + y + z else f2 10 9 | |
in f2 0 10 + y + x | |
f2 :: Int -> (Int -> Int, Int -> Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In Scala methods/functions can be called in different ways. | |
* Here are some possible ways, for the following function/method: | |
*/ | |
def m(n: Int): Int = n + 2 | |
// C-like function/method calls | |
m(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Let's define a class | |
class Animal(val kind: String) | |
// We have a utility class, which defines eats for Animal | |
class AnimalUtils { | |
def eats(p: Animal): String = ... | |
} | |
// We can call eats like that: | |
AnimalUtils.eats(new Animal("sheep")) |