alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (Course-2002-04.check)

This example Scala source code file (Course-2002-04.check) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

list, list

The Scala Course-2002-04.check source code

list0 = List(6, 3, 1, 8, 7, 1, 2, 5, 8, 4, 3, 4, 8)
list1 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
list2 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
list3 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
list4 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
list5 = List(8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2, 1, 1)
list6 = List(8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2, 1, 1)

list0: List() -> List()
list1: List(0) -> List(0)
list2: List(0, 1) -> List(0, 1)
list3: List(1, 0) -> List(0, 1)
list4: List(0, 1, 2) -> List(0, 1, 2)
list5: List(1, 0, 2) -> List(0, 1, 2)
list6: List(0, 1, 2) -> List(0, 1, 2)
list7: List(1, 0, 2) -> List(0, 1, 2)
list8: List(2, 0, 1) -> List(0, 1, 2)
list9: List(2, 1, 0) -> List(0, 1, 2)
listA: List(6, 3, 1, 8, 7, 1, 2, 5, 8, 4) -> List(1, 1, 2, 3, 4, 5, 6, 7, 8, 8)

f(x) = 5x^3+7x^2+5x+9
f(0) = 9.0
f(1) = 26.0
f(2) = 87.0
f(3) = 222.0

v1        = List(2.0, 3.0, 4.0)
v2        = List(6.0, 7.0, 8.0)

id        = List(List(1.0, 0.0, 0.0), List(0.0, 1.0, 0.0), List(0.0, 0.0, 1.0))
m1        = List(List(2.0, 0.0, 0.0), List(0.0, 2.0, 0.0), List(0.0, 0.0, 2.0))
m2        = List(List(1.0, 2.0, 3.0), List(4.0, 5.0, 6.0), List(7.0, 8.0, 9.0))

v1 * v1   = 29.0
v1 * v2   = 65.0
v2 * v1   = 65.0
v1 * v2   = 65.0

id * v1   = List(2.0, 3.0, 4.0)
m1 * v1   = List(4.0, 6.0, 8.0)
m2 * v1   = List(20.0, 47.0, 74.0)

trn(id)   = List(List(1.0, 0.0, 0.0), List(0.0, 1.0, 0.0), List(0.0, 0.0, 1.0))
trn(m1)   = List(List(2.0, 0.0, 0.0), List(0.0, 2.0, 0.0), List(0.0, 0.0, 2.0))
trn(m2)   = List(List(1.0, 4.0, 7.0), List(2.0, 5.0, 8.0), List(3.0, 6.0, 9.0))

List(v1) * id = List(List(2.0, 3.0, 4.0))
List(v1) * m1 = List(List(4.0, 6.0, 8.0))
List(v1) * m2 = List(List(42.0, 51.0, 60.0))

id * List(v1) = List(List(2.0, 3.0, 4.0), List(0.0, 0.0, 0.0), List(0.0, 0.0, 0.0))
m1 * List(v1) = List(List(4.0, 6.0, 8.0), List(0.0, 0.0, 0.0), List(0.0, 0.0, 0.0))
m2 * List(v1) = List(List(2.0, 3.0, 4.0), List(8.0, 12.0, 16.0), List(14.0, 21.0, 28.0))

id * id   = List(List(1.0, 0.0, 0.0), List(0.0, 1.0, 0.0), List(0.0, 0.0, 1.0))
id * m1   = List(List(2.0, 0.0, 0.0), List(0.0, 2.0, 0.0), List(0.0, 0.0, 2.0))
m1 * id   = List(List(2.0, 0.0, 0.0), List(0.0, 2.0, 0.0), List(0.0, 0.0, 2.0))
m1 * m1   = List(List(4.0, 0.0, 0.0), List(0.0, 4.0, 0.0), List(0.0, 0.0, 4.0))
id * m2   = List(List(1.0, 2.0, 3.0), List(4.0, 5.0, 6.0), List(7.0, 8.0, 9.0))
m2 * id   = List(List(1.0, 2.0, 3.0), List(4.0, 5.0, 6.0), List(7.0, 8.0, 9.0))
m1 * m2   = List(List(2.0, 4.0, 6.0), List(8.0, 10.0, 12.0), List(14.0, 16.0, 18.0))
m2 * m1   = List(List(2.0, 4.0, 6.0), List(8.0, 10.0, 12.0), List(14.0, 16.0, 18.0))
m2 * m2   = List(List(30.0, 36.0, 42.0), List(66.0, 81.0, 96.0), List(102.0, 126.0, 150.0))

Other Scala examples (source code examples)

Here is a short list of links related to this Scala Course-2002-04.check source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.