scala early learning

Anonymous function filter () the Map () reduceLeft ( + )

Code:
Experiment a:
Import scala.math._
Object function {
DEF main (args: the Array [String]) {

val testList=Array(1,2,3).map(x=>x*2)
for (i <- testList){
  println(i)
}

def mul(x:Int):Int={
  x*2
}
val newList=testList.map((a:Int)=>mul(a))
for (i <- newList){
  println(i)
}

 //作为值的函数

val num = 3.14

val fun = ceil _ //fun设为ceil函数

//_ 将ceil方法转换成函数

println(fun(num))

}
}

Experiment two:

object high {
def main(args:Array[String]){

def powerOfTwo(x:Int):Int={if(x==0) 1 else 2*powerOfTwo(x-1)}

val wordsList=Array("spark1","hadoop2","flink3","spark2")
val filterList=wordsList.filter((word:String) => word.contains("spark"))

val num=(1 to 3).reduceLeft(_+_)//最终结果是一个数值
(1 to 3).map("*" * _).foreach (println(_))

println(num)

// numList.foreach(println())
println(“过滤前:”)
wordsList.foreach(println())
println(“过滤后:”)
filterList.foreach(println(
))
print(powerOfTwo(3))

}
}
Alt

Centered and pictures with size: Alt

Of course, we have to allow users more convenient, we have increased the drag and drop images.

How to insert a beautiful piece of code

To blog settings page, choose a favorite piece of code you highlight style, highlighted below show the same 代码片.

// An highlighted block
var foo = 'bar';

Generate a list for you

  • project
    • project
      • project
  1. Item 1
  2. Item 2
  3. Item 3
  • Scheduled Tasks
  • mission accomplished

Create a table

A simple table is so created:

project Value
computer $1600
Cellular phone $12
catheter $1

Setting content center, the left and right of abode

Use :---------:centered
using :----------left home
use ----------:right of abode

first row The second column The third column
The first column of text centered The second column of text goes on the right The third column of text Left

SmartyPants

SmartyPants convert ASCII punctuation characters into "smart" printing punctuation HTML entities. E.g:

TYPE ASCII HTML
Single backticks 'Isn't this fun?' ‘Isn’t this fun?’
Quotes "Isn't this fun?" “Isn’t this fun?”
Dashes -- is en-dash, --- is em-dash – is en-dash, — is em-dash

Create a custom list

Markdown
Text-to- HTML conversion tool
Authors
John
Luke

How to create a footnote

A text with a footnote. 1

Notes also essential

Markdown text is converted to HTML .

KaTeX mathematical formulas

You can use LaTeX to render mathematical expressions Katex :

Gamma formula show C ( n ) = ( n 1 ) ! n N \Gamma(n) = (n-1)!\quad\forall n\in\mathbb N by Euler integration

C ( from ) = 0 t from 1 e t d t . \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,.

You can find more information about LaTeX mathematical expressions here Wallpaper .

The new Gantt chart features enrich your article

Mon 06 Mon 13 Mon 20 已完成 进行中 计划一 计划二 现有任务 Adding GANTT diagram functionality to mermaid
  • About Gantt syntax, reference here ,

UML diagrams

UML diagrams can be used for rendering. Mermaid . For example a sequence diagram produced by the following:

张三 李四 王五 你好!李四, 最近怎么样? 你最近怎么样,王五? 我很好,谢谢! 我很好,谢谢! 李四想了很长时间, 文字太长了 不适合放在一行. 打量着王五... 很好... 王五, 你怎么样? 张三 李四 王五

This produces a flow chart. :

链接
长方形
圆角长方形
菱形
  • About Mermaid syntax, reference here ,

FLowchart flow chart

We will still flow chart flowchart of support:

Created with Raphaël 2.2.0 开始 我的操作 确认? 结束 yes no
  • About Flowchart flowchart syntax, reference here .

Export and import

Export

If you want to try to use this editor, you can edit in this article. When you have finished writing an article, found in the toolbar at the top articles exported , generating a .md file or .html file is stored locally.

Importing

If you want to load a .md file you wrote in the toolbar at the top you can choose to import functions corresponding to the extension of the file to import,
continue your creation.


  1. Footnote explanations ↩︎

Published 10 original articles · won praise 5 · Views 927

Guess you like

Origin blog.csdn.net/qq_42774323/article/details/101623810