Skip to content

Commit

Permalink
Merge branch 'master' into python_app_workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sheikhartin committed Mar 27, 2024
2 parents 8114f0c + 71f4d0a commit 67bf078
Show file tree
Hide file tree
Showing 19 changed files with 1,528 additions and 604 deletions.
77 changes: 72 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
### [1.4.2](https://github.com/sheikhartin/farr/releases/tag/1.4.2)

Moving the algorithms library to the [examples](examples) folder.

### [1.4.1](https://github.com/sheikhartin/farr/releases/tag/1.4.1)

A hotfix for interpreting arguments before creating a new environment!

### [1.4.0](https://github.com/sheikhartin/farr/releases/tag/1.4.0)

Enhancements and new features in invocation and operations:

- Added left (`<<`) and right (`>>`) shift operators for binary manipulation.
- Support for binary, octal, and hexadecimal literals.
- Enforced keyword-only arguments for optional parameters to prevent reassignment through positional arguments.
- Enhanced function, struct, and method invocation error handling with improved messages.

### [1.3.1](https://github.com/sheikhartin/farr/releases/tag/1.3.1)

Adding the `functools` module to our native libraries with these useful functions:

- `all`
- `any`
- `map`
- `partial`

### [1.3.0](https://github.com/sheikhartin/farr/releases/tag/1.3.0)

Smarter prefix and postfix operations; and a huge improvement in tests...

Because the use of terms has been reduced to two, now parentheses must be used to separate expressions! For a better understanding, look at the parse trees taken from the execution of code `^ 5 2 == 25;` in the previous version and then the current version:

```diff
- ModuleNode(body=[RelationalOperationNode(row=2,
- column=7,
- operator='EqualEqual',
- left=ArithmeticOperationNode(row=2,
- column=1,
- operator='Power',
- left=IntegerNode(row=2,
- column=3,
- value='5'),
- right=IntegerNode(row=2,
+ ModuleNode(body=[ArithmeticOperationNode(row=2,
+ column=1,
+ operator='Power',
+ left=IntegerNode(row=2,
+ column=3,
+ value='5'),
+ right=RelationalOperationNode(row=2,
+ column=7,
+ operator='EqualEqual',
+ left=IntegerNode(row=2,
- value='2')),
- right=IntegerNode(row=2,
- column=10,
- value='25'))])
+ value='2'),
+ right=IntegerNode(row=2,
+ column=10,
+ value='25')))])
```

### [1.2.0](https://github.com/sheikhartin/farr/releases/tag/1.2.0)

Providing the ability to use all types of assignments even in chained form without any intermediate method...

### [1.1.0](https://github.com/sheikhartin/farr/releases/tag/1.1.0)

For better debugging, we will use a [linter](https://github.com/astral-sh/ruff).
Expand Down Expand Up @@ -25,22 +92,22 @@ Updating our `libs` folder structure...
│ └── funda.farr
- ├── datetime
- │ └── funda.farr
+ datetime.farr
+ ├── datetime.farr
- ├── fs
- │ └── funda.farr
+ fs.farr
+ ├── fs.farr
- ├── logging
- │ └── funda.farr
+ logging.farr
+ ├── logging.farr
├── math
│ ├── funda.farr
│ └── random.farr
- ├── os
- │ └── funda.farr
+ os.farr
+ ├── os.farr
- └── platform
- └── funda.farr
+ platform.farr
+ └── platform.farr
```

### [0.2.0](https://github.com/sheikhartin/farr/releases/tag/0.2.0)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ if rng_start >= rng_end = {
}
for let i in [rng_start..rng_end] = {
if % i 15 == 0 = {
if ((% i 15) == 0) = {
println("...Fizzbuzz");
} else if % i 3 == 0 = {
} else if ((% i 3) == 0) = {
println("...Fizz");
} else if % i 5 == 0 = {
} else if ((% i 5) == 0) = {
println("...Buzz");
} else = {
println("${i}"); // Or just pass `i` as an argument!
Expand Down
37 changes: 37 additions & 0 deletions examples/binary_search/sol01.farr
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Binary search efficiently locates an item in a sorted sequence by
* repeatedly dividing the search interval in half. If the target is less than
* the item in the middle, the search continues in the lower half, otherwise
* in the upper half, until the item is found or the search space is empty.
*/

use math/random;

fn binary_search(let list, let target) = {
let left = 1;
let right = list.length;

while left <= right = {
let mid = (+ / - right left 2 left).toint();
let result = list.[mid];

if result < target = {
left = + mid 1;
} else if result > target = {
right = - mid 1;
} else = {
return! mid;
}
}

return! -1;
}

let nums = random.randint(0, 50, size=10);
let goal = (
readln!("What is your goal number? ")
.toint()
);

println("Generated numbers: ${nums}");
println("Does it exist? ${binary_search(nums, goal)}");
26 changes: 26 additions & 0 deletions examples/bubble_sort/sol01.farr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Bubble sort is a simple sorting algorithm that repeatedly steps through
* the list, compares adjacent elements and swaps them if they are in
* the wrong order. This process is repeated until the list is sorted.
*/

use math/random;

fn bubble_sort(let list) = {
let length = list.length;
for let i in [1..length] = {
for let j in [1..- length i] = {
if list.[j] > list.[+ j 1] = {
let tmp = list.[j];
list.[j] = list.[+ j 1];
list.[+ j 1] = tmp;
}
}
}
return! list;
}

let nums = random.randint(0, 50, size=10);

println("Before sorting: ${nums}");
println("After sorting: ${bubble_sort(nums)}");
6 changes: 3 additions & 3 deletions examples/fizzbuzz/sol01.farr
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ if rng_start >= rng_end = {
}

for let i in [rng_start..rng_end] = {
if % i 15 == 0 = {
if ((% i 15) == 0) = {
println("...Fizzbuzz");
} else if % i 3 == 0 = {
} else if ((% i 3) == 0) = {
println("...Fizz");
} else if % i 5 == 0 = {
} else if ((% i 5) == 0) = {
println("...Buzz");
} else = {
println("${i}"); // Or just pass `i` as an argument!
Expand Down
6 changes: 3 additions & 3 deletions examples/rock_paper_scissors/sol01.farr
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ for let i in [1..rounds] = {
if user_move == computer_move = {
println("It's a tie!");
} else if (
(user_move == "r" && computer_move == "s") ||
(user_move == "p" && computer_move == "r") ||
(user_move == "s" && computer_move == "p")
((user_move == "r") && (computer_move == "s")) ||
((user_move == "p") && (computer_move == "r")) ||
((user_move == "s") && (computer_move == "p"))
) = {
println("Unfortunately, you won!");
} else = {
Expand Down
2 changes: 1 addition & 1 deletion farr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

__author__ = 'Artin Mohammadi <[email protected]>'
__license__ = 'MIT'
__version__ = '1.1.0'
__version__ = '1.4.2'
Loading

0 comments on commit 67bf078

Please sign in to comment.