-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_syntax__boxy
189 lines (136 loc) · 3.77 KB
/
new_syntax__boxy
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
Degişkenler
[[ let x := 5 ]]
[[ let y := 10 ]]
[[ let z := x + y ]]
fonksiyon
[[ fn add(a, b) =>
[[ return a + b ]]
]]
[[ let result := add(3, 7) ]]
şart ve kontrol
[[ if [x > y] then
[[ print("x is greater") ]]
else
[[ print("y is greater") ]]
]]
Döngü
[[ let i := 0 ]]
[[ loop [i < 5] do
[[
print(i)
let i := i + 1
]]
]]
## Bu, Boxy dilinde bir örnek koddur
[[ let i := 0 ]]
## Fonksiyon tanımlama
[[ fn add(a, b) =>
[[ return a + b ]]
]]
## Döngü ile sayıları yazdırma
[[ loop [i < 10] do
[[
print(i)
let i := i + 1
]]
]]
## Koşul ifadeleri
[[ if [i == 10] then
[[ print("i is now 10") ]]
else
[[ print("i is not 10 yet") ]]
]]
## Matrix tanımlama
[[ let A := [[1, 2, 3], [4, 5, 6], [7, 8, 9]] ]]
[[ let B := [[9, 8, 7], [6, 5, 4], [3, 2, 1]] ]]
## Matrix toplama fonksiyonu
[[ fn matrix_add(A, B) =>
[[
let result := []
for i in range(len(A)):
[[
let row := []
for j in range(len(A[0])):
[[
row.append(A[i][j] + B[i][j])
]]
result.append(row)
]]
return result
]]
]]
## Matrix toplama işlemi
[[ let C := matrix_add(A, B) ]]
## Matrix çarpma fonksiyonu
[[ fn matrix_multiply(A, B) => [[ let result := [[0 for _ in range(len(B[0]))] for _ in range(len(A))]
for i in range(len(A)):
[[ for j in range(len(B[0])):
[[ for k in range(len(B)): [[ result[i][j] += A[i][k] * B[k][j]
]]
]]
]]
return result
]]
]]
## Matrix çarpma işlemi
[[ let D := matrix_multiply(A, B) ]]
## Matrix transpoz fonksiyonu
[[ fn matrix_transpose(A) => [[ let result := [[0 for _ in range(len(A))] for _ in range(len(A[0]))]
for i in range(len(A)):
[[ for j in range(len(A[0])):
[[ result[j][i] = A[i][j]
]]
]]
return result
]]
]]
## Matrix transpoz işlemi
[[ let E := matrix_transpose(A) ]]
python ile kullanımı
[[ import numpy as np ]]
## NumPy kullanarak matrix tanımlama
[[ let A := np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) ]]
[[ let B := np.array([[9, 8, 7], [6, 5, 4], [3, 2, 1]]) ]]
## Matrix toplama
[[ let C := np.add(A, B) ]]
## Matrix çarpma
[[ let D := np.dot(A, B) ]]
## Matrix transpoz
[[ let E := np.transpose(A) ]]
[[ import pandas as pd ]]
## Pandas kullanarak DataFrame tanımlama
[[ let df := pd.DataFrame({
'A': [1, 2, 3],
'B': [4, 5, 6],
'C': [7, 8, 9]
}) ]]
## DataFrame sütun ekleme
[[ df['D'] := df['A'] + df['B'] ]]
## DataFrame filtreleme
[[ let filtered_df := df[df['A'] > 1] ]]
[[ class Person ]]
[[ let name := "" ]]
[[ let age := 0 ]]
[[ fn __init__(self, name, age) =>
[[ self.name := name ]]
[[ self.age := age ]]
]]
[[ fn greet(self) =>
[[ print(f"Hello, my name is {self.name} and I am {self.age} years old.") ]]
]]
## Person sınıfından bir nesne oluşturma
[[ let john := Person("John", 30) ]]
[[ john.greet() ]]
[[ class Employee extends Person ]]
[[ let employee_id := 0 ]]
[[ fn __init__(self, name, age, employee_id) =>
[[ super().__init__(name, age) ]]
[[ self.employee_id := employee_id ]]
]]
[[ fn show_employee_id(self) =>
[[ print(f"My employee ID is {self.employee_id}") ]]
]]
## Employee sınıfından bir nesne oluşturma
[[ let jane := Employee("Jane", 28, 1234) ]]
[[ jane.greet() ]]
[[ jane.show_employee_id() ]]