Skip to content

Commit 8f57605

Browse files
authored
Update README.md
1 parent c8a7553 commit 8f57605

File tree

1 file changed

+66
-11
lines changed

1 file changed

+66
-11
lines changed

README.md

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,26 @@ Simplify Data Workflows by Combining Programming and Data Operations! <br>
33
Designed to work with data stream operations directly on common data formats such as JSON and CSV. <br>
44
*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.
55

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 <a name="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 <a name="example"></a>
726

827
```js
928
weather_data = load("./weather-data.json", "json") // open json file
@@ -23,26 +42,62 @@ print3("Is Bern the best city?: idk, im a computer")
2342
print3("Has Bern continuous data?:")
2443
index = 1
2544
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"]) {
2847
continuous_data = false
2948
}
49+
3050
index = index + 1
3151
}
3252
print3(continuous_data)
3353
```
3454
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>
3656
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.
3757

38-
## Build Instructions
58+
### Anonymous functions <a name="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+
return check_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: <a name="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 <a name="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`.
92+
93+
## Build Instructions <a name="build"></a>
3994

40-
### Prerequisites
95+
### Prerequisites <a name="pre"></a>
4196

4297
- [Scala 3.X](https://www.scala-lang.org/download/)
4398
- Recent Java SDK (openjdk 22 for example)
4499

45-
### Building in Terminal/Shell
100+
### Building in Terminal/Shell <a name="build_sh"></a>
46101

47102
Run the following commands in the project root.
48103

@@ -63,7 +118,7 @@ sbt "run args..."
63118

64119
The quotes are neccessary here because otherwise they would be interpreted as a new command from sbt.
65120

66-
### Building in intellij IDEA
121+
### Building in intellij IDEA <a name="build_idea"></a>
67122

68123
#### Installing Plugins
69124

@@ -82,16 +137,16 @@ Once done hit 'Apply' or 'OK' to finish the task setup.
82137

83138
Now you should be able to build/run/package/... the project depending on what you chose as a task.
84139

85-
### Unit testing and Python Script testing
140+
### Unit testing and Python Script testing <a name="testing"></a>
86141

87-
#### Unit testing
142+
#### Unit testing <a name="unit"></a>
88143

89144
Similar to building in the terminal you execute the following for the scala unit tests:
90145
```sh
91146
sbt test
92147
```
93148

94-
#### Python Script testing
149+
#### Python Script testing <a name="python"></a>
95150

96151
These tests involve a bit more work to be run.
97152
For the duration of these steps I assume you are at the root of the project.

0 commit comments

Comments
 (0)