forked from Bridgewater/scala-notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.+Basics.snb
87 lines (87 loc) · 2.68 KB
/
1.+Basics.snb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
"metadata":{
"name":"1. Basics",
"user_save_timestamp":"2015-02-05T18:24:57.792Z",
"auto_save_timestamp":"2015-02-05T18:24:45.938Z"
},
"worksheets":[{
"cells":[{
"cell_type":"markdown",
"source":"## Welcome to Scala Notebook\n\nScala notebook is an interactive REPL. You type scala expressions in the browser, and they are evaluated in a Kernel behind the scenes. Cells can contain formatting or code."
},{
"cell_type":"markdown",
"source":"To edit a markdown cell, double-click in the text. "
},{
"cell_type":"code",
"input":"// Simple expressions\nList(1,2,3,4).reverse\n",
"language":"scala",
"collapsed":false,
"prompt_number":7,
"outputs":[]
},{
"cell_type":"code",
"input":"// Functions\ndef fact(n: Int): Int = if (n == 0) 1 else n*fact(n-1)",
"language":"scala",
"collapsed":false,
"prompt_number":8,
"outputs":[]
},{
"cell_type":"code",
"input":"// Functions are callable after they are defined. By convention, notebooks evaluate from top to bottom\n// but you must evaluate a cell before it is used\nfact(10)",
"language":"scala",
"collapsed":false,
"prompt_number":9,
"outputs":[]
},{
"cell_type":"code",
"input":"notarealexpression * 2",
"language":"scala",
"collapsed":false,
"prompt_number":10,
"outputs":[]
},{
"cell_type":"code",
"input":"sys.error(\"explode!\")",
"language":"scala",
"collapsed":false,
"prompt_number":11,
"outputs":[]
},{
"cell_type":"code",
"input":"// HTML return types are also suppored\n<table>{ for (row <- 1 to 5) yield \n <tr>{ for (col <- 1 to 4) yield <td>{row*col}</td> }</tr>\n} </table>",
"language":"scala",
"collapsed":false,
"prompt_number":12,
"outputs":[]
},{
"cell_type":"code",
"input":"<img src=\"http://i.imgur.com/EQ1uJ8i.gif\" />",
"language":"scala",
"collapsed":false,
"prompt_number":13,
"outputs":[]
},{
"cell_type":"code",
"input":"// stdout streams in real-time\nfor (i <- 1 to 10) yield {\n Thread.sleep(500)\n println(i)\n i\n}\n",
"language":"scala",
"collapsed":false,
"prompt_number":14,
"outputs":[]
},{
"cell_type":"code",
"input":"// widgets is available because of imports in init.sc\nwidgets.text(\"Hello, World!\")",
"language":"scala",
"collapsed":false,
"prompt_number":15,
"outputs":[]
},{
"cell_type":"code",
"input":"",
"language":"scala",
"collapsed":true,
"outputs":[]
}]
}],
"autosaved":[],
"nbformat":3
}