This repository was archived by the owner on Apr 25, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +51
-25
lines changed
Expand file tree Collapse file tree 3 files changed +51
-25
lines changed Original file line number Diff line number Diff line change 11"""
22I Language types.
3- Version: 0.1.1
3+ Version: 0.1.2
44
55Copyright (c) 2023-present ElBe Development.
66
@@ -88,20 +88,6 @@ def __init__(self, value: str) -> None:
8888 super ().__init__ (value , _Any )
8989
9090
91- class Array (BaseType ):
92- """
93- Array type.
94- """
95-
96- def __init__ (self , value : str ) -> None :
97- """Initializes an array type.
98-
99- :param value: Value of the object to check for array value.
100- """
101-
102- super ().__init__ (value , builtins .list )
103-
104-
10591@final
10692class Bool (BaseType ):
10793 """
@@ -221,18 +207,32 @@ def __init__(self, value: str) -> None:
221207
222208
223209@final
224- class List (Array ):
210+ class List (BaseType ):
225211 """
226- Array type.
212+ List type.
227213 """
228214
229215 def __init__ (self , value : str ) -> None :
230- """Initializes an array type.
216+ """Initializes a list type.
231217
232- :param value: Value of the object to check for array value.
218+ :param value: Value of the object to check for list value.
233219 """
234220
235- super ().__init__ (value )
221+ super ().__init__ (value , builtins .list )
222+
223+
224+ class Null (BaseType ):
225+ """
226+ None type.
227+ """
228+
229+ def __init__ (self , value : str ) -> None :
230+ """Initializes a none type.
231+
232+ :param value: Value of the object to check for none value.
233+ """
234+
235+ super ().__init__ (value ) # TODO (ElBe): Find null type
236236
237237
238238class Str (BaseType ):
Original file line number Diff line number Diff line change 4747SEPARATORS : Final [List [str ]] = [" " , "\t " , "\n " ]
4848DOUBLE_MARKS : Final [Dict [str , str ]] = {
4949 "==" : "EQUAL" ,
50- "===" : "TYPE_EQUAL" ,
50+ "<=" : "LESS_EQUALS" ,
51+ ">=" : "GREATER_EQUALS" ,
5152 "++" : "COUNT_UP" ,
5253 "--" : "COUNT_DOWN" ,
5354}
8889}
8990BASE_TYPES : Final [List [str ]] = [
9091 "any" ,
91- "array" ,
9292 "bool" ,
9393 "complex" ,
9494 "dict" ,
100100 "list" ,
101101 "str" ,
102102 "string" ,
103- "None" ,
104- "Null" ,
103+ "null" ,
105104]
106105
107106
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import _core
3636////////////////////
3737
3838int randint(int minimum, int maximum) {
39+
3940 return _core.Random.randint(minimum, maximum)
4041}
4142
@@ -44,8 +45,34 @@ int randint(int minimum, int maximum) {
4445// CHOICES //
4546/////////////
4647
48+ /*
49+ * Returns a random value from a given list.
50+ *
51+ * @params
52+ * iterable (list): List to return a random choice from.
53+ * choices (list): Choices to return form the iterable. If choices is bigger than the iterable, the remaining values will be skipped.
54+ *
55+ * @return
56+ * Any: Chosen object(s) from the iterable.
57+ */
4758function choices(list iterable, int choices = 1) {
4859 return _core.Random.choices(iterable, choices)
4960}
5061
51- // TODO (ElBe): Add shuffle
62+
63+ /////////////
64+ // SHUFFLE //
65+ /////////////
66+
67+ /*
68+ * Returns a shuffled version of the given list.
69+ *
70+ * @params
71+ * iterable (list): List to shuffle.
72+ *
73+ * @return
74+ * list: Shuffled list.
75+ */
76+ list shuffle(list iterable) {
77+ return _code.Random.shuffle(iterable)
78+ }
You can’t perform that action at this time.
0 commit comments