mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-25 22:38:04 +02:00
Added Scala example
This commit is contained in:
parent
420b6b31fd
commit
7e76256e4e
8 changed files with 60 additions and 5 deletions
8
documents/Programmierparadigmen/scripts/c/pointer.c
Normal file
8
documents/Programmierparadigmen/scripts/c/pointer.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int arr[] = {0,1,2,3,4,5};
|
||||
|
||||
int main() {
|
||||
printf("%i %i", arr[0], (&arr[3])[0]);
|
||||
return 0;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
type Prename = String
|
||||
type Age = Double
|
||||
type Person = (Prename, Age)
|
||||
type Friends = [Person]
|
||||
type Friends = [Person]
|
||||
type Polynom = [Double]
|
|
@ -0,0 +1,4 @@
|
|||
data Bool = False | True
|
||||
data Color = Red | Green | Blue | Indigo | Violet
|
||||
data Tree a = Leaf a | Branch (Tree a) (Tree a)
|
||||
data Point = Point Float Float deriving (Show)
|
24
documents/Programmierparadigmen/scripts/scala/weather.scala
Normal file
24
documents/Programmierparadigmen/scripts/scala/weather.scala
Normal file
|
@ -0,0 +1,24 @@
|
|||
import scala.io._
|
||||
import scala.xml.{Source => Source2, _}
|
||||
import scala.actors._
|
||||
import Actor._
|
||||
|
||||
def getWeatherInfo(woeid: String) = {
|
||||
val url = "http://weather.yahooapis.com/forecastrss?w=" + woeid
|
||||
val response = Source.fromURL(url).mkString
|
||||
val xmlResponse = XML.loadString(response)
|
||||
println(xmlResponse \\ "location" \\ "@city",
|
||||
xmlResponse \\ "condition" \\ "@temp")
|
||||
}
|
||||
|
||||
val caller = self
|
||||
|
||||
for(id <- 2391271 to 2391279) {
|
||||
actor{ getWeatherInfo(id.toString) }
|
||||
}
|
||||
|
||||
for(id <- 2391271 to 2391279) {
|
||||
receiveWithin(5000) {
|
||||
case msg => println(msg)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue