You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+66-11Lines changed: 66 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,26 @@ Simplify Data Workflows by Combining Programming and Data Operations! <br>
3
3
Designed to work with data stream operations directly on common data formats such as JSON and CSV. <br>
4
4
*YADL* is a Turing-complete language and was created in a group at university. Thanks to all of them. This repository is a re-upload.
5
5
6
-
## Example
6
+
## Table of Contents
7
+
1.[Introduction](#intro)
8
+
1.[Example](#example)
9
+
2.[Anonymous Functions](#anonymous)
10
+
3.[Commong Bugs](#bugs)
11
+
2.[Quick Start/Installation](#start)
12
+
3.[Build Instructions](#build)
13
+
1.[Prerequisites](#pre)
14
+
2.[Building in Terminal/Shell](#build_sh)
15
+
3.[Building in intellij IDEA](#build_idea)
16
+
4.[Testing of Code](#testing)
17
+
1.[Unit testing](#unit)
18
+
1.[Testing with pytest](#python)
19
+
20
+
21
+
## Introduction <aname="intro" />
22
+
23
+
> Beyond basic queries, SQL struggles with complex data manipuiation. APIs often return data in JSON format, requiring additional parsing. YADL bridges the gap, offering built-in functionality for both - write less code, analyze more effectively. It's a programming language that allows to parse different file types (json, csv, etc.) with a singe load function and to work with data operations on it.
24
+
25
+
### Example <aname="example"></a>
7
26
8
27
```js
9
28
weather_data =load("./weather-data.json", "json") // open json file
@@ -23,26 +42,62 @@ print3("Is Bern the best city?: idk, im a computer")
23
42
print3("Has Bern continuous data?:")
24
43
index =1
25
44
continuous_data =true
26
-
while (index <len(bern) && continuous_data) {
27
-
if (bern[index-1]["day"] +1!= bern[index]["day"]) {
45
+
while (index <len(bern) and continuous_data) {
46
+
if (bern[index-1]["day"] +1!= bern[index+0]["day"]) {
28
47
continuous_data =false
29
48
}
49
+
30
50
index = index +1
31
51
}
32
52
print3(continuous_data)
33
53
```
34
54
Assuming there is the file `weather-data.json`, this file will use functions, loops and if-statements to analyze the data in the JSON. This is of course only a small demonstration. <br>
35
-
Functions, that are not specifically declared in this example are inbuilt functions. For all in-built functions (with description), [click here](spec/stdlib/iterator methods.md). <br>
55
+
Functions, that are not specifically declared in this example are inbuilt functions. For all in-built functions (with description), [click here](https://github.com/julianjumper/yadl/blob/main/spec/stdlib/iterator%20methods.md). <br>
36
56
Please keep in mind, that this project was created in a short period of time. This has not reach its full potential. The most important idea we had in mind, is to load the data chunk-wise so that not all data needs to be stored in memory.
37
57
38
-
## Build Instructions
58
+
### Anonymous functions <aname="anonymous"></a>
59
+
60
+
We also have anonymous functions! <br>
61
+
This code from the example uses one:
62
+
```js
63
+
has_freezing_days= (city) => {
64
+
returncheck_any(city, (item) => item["temp"] <0)
65
+
}
66
+
print3("Is it freezing?", has_freezing_days(bern)
67
+
```
68
+
Notice this line: `check_any(city, (item) => item["temp"] <0)` <br>
69
+
Right there, we use the anonymous function `(item) => item["temp"] <0)` which returns true, if attribute "temp" of the passed object "item" is below 0. <br>
70
+
Is this example, it is passed to one of our in-built function from the standard library `check_any` (["see here"](https://github.com/julianjumper/yadl/blob/main/spec/stdlib/iterator%20methods.md) for more information). It is a higher-order function, which takes the anonymous function as an argument.
71
+
72
+
But we can also immediately call anonymous functions instead:
73
+
```js
74
+
print3("2 + 1:", ((a,b) => a+b)(2,1))
75
+
```
76
+
77
+
### Common bugs: <aname="bugs"></a>
78
+
- In the example, you might have noticed the `index+0` in the if-statement. This is because the parser expects a value of an operation. I will fix it when I have time! <br>
79
+
btw, `index+0` is an easy fix - in our group we made fun of this bug by using an anonymous identity function and passing the wanted value: `((i) => i)(index)`🤪
80
+
- After an if-statement, you have to insert a blank line - also an issue with the parser.
81
+
82
+
## Quick Start/Installation <aname="start"></a>
83
+
84
+
### Download JAR
85
+
86
+
- download the JAR from this GitHub repository
87
+
88
+
### Running a `.yadl` file
89
+
Run this command:
90
+
`java -jar <path-to-jar> <path-to-yadl>`
91
+
path-to-jar is the path to the downloaded jar-file and path-to-yadl the path to your yadl program. You can download and use the test file `fancy-tests/wather-data.yadl`.
0 commit comments