Last active
December 20, 2015 07:29
-
-
Save kencoba/6093972 to your computer and use it in GitHub Desktop.
Multiplication table of Tetrahedral group.
This file contains hidden or 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
val id = "ABCD" //> id : String = ABCD | |
val tl = "BADC" //> tl : String = BADC | |
val tm = "DCBA" //> tm : String = DCBA | |
val tn = "CDAB" //> tn : String = CDAB | |
val a1 = "ACDB" //> a1 : String = ACDB | |
val a2 = "ADBC" //> a2 : String = ADBC | |
val b1 = "DBAC" //> b1 : String = DBAC | |
val b2 = "CBDA" //> b2 : String = CBDA | |
val c1 = "BDCA" //> c1 : String = BDCA | |
val c2 = "DACB" //> c2 : String = DACB | |
val d1 = "CABD" //> d1 : String = CABD | |
val d2 = "BCAD" //> d2 : String = BCAD | |
val ss = List(id,tl,tm,tn,a1,a2,b1,b2,c1,c2,d1,d2) | |
val ks = List("id","tl","tm","tn","a1","a2","b1","b2","c1","c2","d1","d2") | |
def mapping(s:String) = { | |
(c: Char) => { | |
c match { | |
case 'A' => s.charAt(0) | |
case 'B' => s.charAt(1) | |
case 'C' => s.charAt(2) | |
case 'D' => s.charAt(3) | |
} | |
} | |
} | |
def comp(f:String, g:String) = { | |
def mf = mapping(f) | |
def mg = mapping(g) | |
{for (c <- "ABCD".toList) yield mg(mf(c))}.mkString | |
} | |
for (g <- ss) { | |
for (f <- ss) { | |
print( ks(ss.indexOf(comp(f,g))) + " ") | |
} | |
println | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment