01.爻變演算法


第二題 使用 Scala 函數編程思維來設計易經中爻變相關的演算規則

分宮卦序爻變與錯綜卦用工具類


package chaoyi.kuo.iching

/**
 * @author ChaoYi, Kuo
 * 爻變用
 */
object YaoChange {

/*
* 爻變
*/
val yaoChaonge = (gua64: List[Boolean], yao: Int) => !gua64(yao-1)


/*
* 綜卦
*/
val reverseGua = (gua64: List[Boolean]) => gua64 reverse

/*
* 錯卦
*/
val reverseYaoGua = (gua64: List[Boolean]) => gua64 map(!_)

/*
* 互卦分上下
*/

}



待處理idea
    1. 分宮卦象的七種處理未撰寫



    UnitTest

    package chaoyi.kuo.iching.test

    import chaoyi.kuo.iching._

    object MainTest {
    def main(args : Array[String]) : Unit = {
    // println(Gua64.g01)
    println(Gua64.g11)
    println(YaoChange.reverseGua(Gua64.g11))
    println(YaoChange.yaoChaonge(Gua64.g11, 4))
    println(YaoChange.reverseYaoGua(Gua64.g11))
    println(Gua64.g30)
    println(YaoChange.reverseYaoGua(Gua64.g30))
    }

    }

    /*

    List(false, false, false, true, true, true)

    List(true, true, true, false, false, false)

    false

    List(true, true, true, false, false, false)

    List(true, false, true, true, false, true)

    List(false, true, false, false, true, false)

    */



    Comments