随笔分类 - scala
摘要:package spark.demo object MyApp2 { // 部分适用 def msg (from: String, to: String, text: String) = s"($from -> $to): $text" def main(args: Array[String]):
阅读全文
摘要:package spark.demoobject MyApp { def main(args: Array[String]): Unit = { // 函数柯理化 val multiFunc = (a: Int, b: Int) => a * b val multiFuncCurried = (a:
阅读全文
摘要:scala> val add = (x: Int, y: Int) => x + y add: (Int, Int) => Int = <function2> scala> // add: (Int, Int) => Int = <function2> scala> scala> val addCu
阅读全文
摘要:######################### 高阶函数 ######################### scala> def sum(x: Int) = x + 1 sum: (x: Int)Int scala> println(sum(5)) 6 Lamda表达式 scala> val
阅读全文
摘要:scala> val number = Seq(20, 40, 60) number: Seq[Int] = List(20, 40, 60) scala> val numbers = (x: Int) => x * 2 numbers: Int => Int = <function1> scala
阅读全文
摘要:scala> val f: String => Int = arg => arg.toInt * 2 f: String => Int = <function1> scala> f res0: String => Int = <function1> scala> f("5") res1: Int =
阅读全文
摘要:package spark.demo object Demo { def main(args: Array[String]) { val m: Map[Int, String] = Map(3 -> "Python", 1 -> "Java", 2 -> "Scala", 6 -> "SQL") /
阅读全文
摘要:高阶函数的基本构成 def 方法名(函数名: (函数的参数类型) => 函数的返回值类型) { 处理的具体内容 } 案例 package com.spark.demo object HigherOrderFunction { def main(args: Array[String]): Unit =
阅读全文
摘要:Microsoft Windows [版本 10.0.17763.1282] (c) 2018 Microsoft Corporation。保留所有权利。 c:\desktop>scala Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server
阅读全文
浙公网安备 33010602011771号