Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Add Byte and Raw String #171

Merged
merged 12 commits into from
Jan 25, 2024
4 changes: 2 additions & 2 deletions examples/reference/atomic_pipe_back_expressions.jac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
with entry {
print <: "Hello world!" ; # print("Hello world!")
print <: "Hello world!" ;
a = [2,4,5,7,8];
b = [4,8,9,13,20];
c = len<:a + len<:b ; #len(a) + len(b)
c = len<:a + len<:b ;
print(c);

}
2 changes: 0 additions & 2 deletions examples/reference/delete_statements.jac
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ with entry{

del x;

# Raises NameError because x is deleted
#print("After Delete:", x);
}
3 changes: 0 additions & 3 deletions examples/reference/delete_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
print("Before Delete:", x)

del x

# Raises NameError because x is deleted
# print("After Delete:", x)
16 changes: 8 additions & 8 deletions examples/reference/f_string_tokens.jac
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ with entry{
x = "a";
y = 25;

# tokens =f"Hello {x} {y} {{This is an escaped curly brace}}";
# print(tokens);

person = {"name": "Jane", "age": 25};
print(f"Hello, {person['name']}! You're {person['age']} years old.");
print(f"Hello {x} {y} {{This is an escaped curly brace}} mm""jhjvhvjh");

print("This is the first line.\n This is the second line.");
print("This willnot print.\r This will be printed");
print("This is \t tabbed.");
print("Line 1\fLine 2");
# person = {"name": "Jane", "age": 25};
# print(f"Hello, {person['name']}! You're {person['age']} years old.");

# print("This is the first line.\n This is the second line.");
# print("This willnot print.\r This will be printed");
# print("This is \t tabbed.");
# print("Line 1\fLine 2");

# words = ["Hello", "World!", "I", "am", "a", "‘Jactastic’ !"];
# print(f"{'\n'.join(words)}");
Expand Down
10 changes: 3 additions & 7 deletions examples/reference/for_statements.jac
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
with entry{
start_range = 1;
end_range = 5;

for i in range(start_range, end_range + 1){
for number = 1 to number<=10 by number+=1{
product = i * number;
print(f"{i} x {number} = {product}");
for i in range(1, 4 ){
for j = 1 to j<3 by j+=1{
print(i,j);
}
print("\n", end="");
}

}
Expand Down
12 changes: 3 additions & 9 deletions examples/reference/for_statements.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
start_range = 1
end_range = 5
for i in range(start_range, end_range + 1):
number = 1
while number <= 10:
product = i * number
print(f"{i} x {number} = {product}")
number += 1
print("\n", end="")
for i in "banana":
for j in range(1, 3):
print(i, j)
10 changes: 5 additions & 5 deletions examples/reference/lambda_expressions.jac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
with entry{
# Example usage of the lambda function
calculate_rectangle_area = with length: float, width: float can length * width;
rectangle_area = calculate_rectangle_area(5.0, 8.0);

print(f"The area of the rectangle is: {rectangle_area}");
x = with a: int , b:int can a+b;
print(x(5,4));

}


}
11 changes: 2 additions & 9 deletions examples/reference/lambda_expressions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
calculate_rectangle_area = lambda length, width: length * width

# Example usage
length = 5.0
width = 8.0

area = calculate_rectangle_area(length, width)

print(f"The area of the rectangle is: {area}")
x = lambda a, b: a + b
print(x(5, 4))
71 changes: 12 additions & 59 deletions examples/reference/logical_and_compare_expressions.jac
Original file line number Diff line number Diff line change
@@ -1,64 +1,17 @@

with entry{
apples = 5;
oranges = 8;

# Check if there are more oranges than apples
if oranges > apples{
print("There are more oranges than apples.");
}
else{
print("There are fewer oranges than apples.");
}
}

with entry{
city1 = "New York";
city2 = "Los Angeles";

# Check if the cities are the same
if city1 == city2{
print("Both cities are the same.");
}
else{
print("The cities are different.");
}

}

with entry{
# Using is for identity comparison
list1 = [1, 2, 3];
list2 = [1, 2, 3];

if list1 is list2{
print("list1 and list2 refer to the same object.");
}
else{
print("list1 and list2 are different objects.");
}

}
with entry{
# Example with a list
my_list = [1, 2, 3, 4, 5];
result = 3 in my_list;
print(result); # Output: True

}

#logical OR,AND .jac
with entry{
is_star_player = True; # Player is a star player
has_high_score = False; # Player has a high score in the game
is_team_captain = True; # Player is the team captain

# Logical OR: Star Player or High Score
access_allowed_or = is_star_player or has_high_score;
print(f"Access allowed (OR): {access_allowed_or}"); # Output: True
if 5 < 4{
print("True");}
elif "a" != "b"{
print("'a' is 'a' ");}
else{
print("No");}

# Logical AND: Team Captain and Star Player
access_allowed_and = is_team_captain and is_star_player;
print(f"Access allowed (AND): {access_allowed_and}"); # Output: True
a = [1, 2, 3];
b = [1, 2, 3];
print(a is b);
print( 3 in a);

print(True or False);
print(False and False);
}
58 changes: 12 additions & 46 deletions examples/reference/logical_and_compare_expressions.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,13 @@
apples = 5
oranges = 8

if oranges > apples:
print("There are more oranges than apples.")
else:
print("There are fewer oranges than apples.")


city1 = "New York"
city2 = "Los Angeles"

# Check if the cities are the same
if city1 == city2:
print("Both cities are the same.")
else:
print("The cities are different.")


list1 = [1, 2, 3]
list2 = [1, 2, 3]

if list1 is list2:
print("list1 and list2 refer to the same object.")
if 5 > 4:
print("True")
elif "a" == "a":
print("'a' is 'a' ")
else:
print("list1 and list2 are different objects.")


# in
my_list = [1, 2, 3, 4, 5]
result = 3 in my_list
print(result) # Output: True

is_star_player = True
# Player is a star player
has_high_score = False
# Player has a high score in the game
is_team_captain = True
# Player is the team captain

# Logical OR: Star Player or High Score
access_allowed_or = is_star_player or has_high_score
print(f"Access allowed (OR): {access_allowed_or}") # Output: True

# Logical AND: Team Captain and Star Player
access_allowed_and = is_team_captain and is_star_player
print(f"Access allowed (AND): {access_allowed_and}") # Output: True
print("False")
a = [1, 2, 3]
b = [1, 2, 3]
print(a is b)
print(3 in a)

print(True or False)
print(False and False)
13 changes: 5 additions & 8 deletions examples/reference/match_capture_patterns.jac
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
with entry{
data=" snoopy";
day=" sunday";

match data{
case "Ironman":
print("You are Marvel fan");
case "Batman":
print("You are DC fan");
match day{
case "monday":
print("confirmed");
case _:
print("You are not a Marvel or DC fan");

print("other");
}
}
13 changes: 5 additions & 8 deletions examples/reference/match_capture_patterns.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
data = "snoopy"
match data:
case "Ironman":
print("You are Marvel fan")

case "Batman":
print("You are DC fan")
day = " sunday"
match day:
case "monday":
print("confirmed")
case _:
print("You are not a Marvel or DC fan")
print("other")
8 changes: 6 additions & 2 deletions examples/reference/match_class_patterns.jac
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ with entry{

match data {

# MatchClass
case Point(int(a), y=0):
print(f"Point with x={a} and y=0");
case _ :
print("Not on the x-axis");
}
}
}



2 changes: 2 additions & 0 deletions examples/reference/match_class_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ class Point:
match data:
case Point(int(a), y=0):
print(f"Point with x={a} and y=0")
case _:
print("Not on the x-axis")
3 changes: 0 additions & 3 deletions examples/reference/match_litteral_patterns.jac
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
with entry{
num=89;
match num{
# MatchSequence
case 89:
print("Correct");
case 8:
print("Nope");
case 9:
print("Nope");
}
}
3 changes: 0 additions & 3 deletions examples/reference/match_litteral_patterns.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
num = 89
match num:
# MatchSequence
case 89:
print("Correct")
case 8:
print("Nope")
case 9:
print("Nope")
1 change: 0 additions & 1 deletion examples/reference/match_mapping_patterns.jac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

data={"key1":1,"key2":2,"232":3453};

# MatchMapping
match data{
case {"key1": 1, "key2": 2, **rest}:
print(f"Matched a mapping with key1 and key2. Rest: {rest}");
Expand Down
1 change: 0 additions & 1 deletion examples/reference/match_mapping_patterns.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
data = {"key1": 1, "key2": 2, "232": 3453}

# MatchMapping
match data:
case {"key1": 1, "key2": 2, **rest}:
print(f"Matched a mapping with key1 and key2. Rest: {rest}")
5 changes: 3 additions & 2 deletions examples/reference/match_sequence_patterns.jac
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
with entry{
data=[1,2,3];
match data{
# MatchSequence
case [1, 2, 3]:
print("Matched a specific sequence [1, 2, 3].");
print("Matched");
case _:
print("Not Found");
}
}
5 changes: 3 additions & 2 deletions examples/reference/match_sequence_patterns.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# MatchSequence
data = [1, 2, 3]
match data:
case [1, 2, 3]:
print("Matched a specific sequence [1, 2, 3].")
print("Matched")
case _:
print("Not Found")
8 changes: 3 additions & 5 deletions examples/reference/match_statements.jac
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ with entry {
a=8;
match a {
case 7:
print("Nope");
case 8:
print("Yep");
print("doable");
case _:
print("Not possible");
print("Undoable");
}
}
}
6 changes: 2 additions & 4 deletions examples/reference/match_statements.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
a = 8
match a:
case 7:
print("Nope")
case 8:
print("Yep")
print("Doable")
case _:
print("Not possible")
print("Undoable")
1 change: 0 additions & 1 deletion examples/reference/raise_statements.jac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ can foo(value : int){
}
}

#have to use KW_FROM
with entry{
try{
foo(-1);
Expand Down
Loading
Loading