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))
}
}
Centered and pictures with size:
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
- project
- Item 1
- Item 2
- 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 by Euler integration
You can find more information about LaTeX mathematical expressions here Wallpaper .
The new Gantt chart features enrich your article
- 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:
- 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.
Footnote explanations ↩︎