-
Notifications
You must be signed in to change notification settings - Fork 20
Data Types Modules. #15
Comments
Author : @Youngestdev Pheew. Update. The push method.The push method has been built into two ways. 1. addToList(list, value).This above, is a function to add a value to the List / Array. This function cannot be appended to the list variable directly. In this case, the list argument in the array stand for the array that an element will be added to and the value is that element ( number, string, list ) that'll be added to the array.
2. .push (x)This is binded to the List class. To use this, you'll have to declare list using a class declaration structure. Take a look at the Example below:
Unfortunately, I'm still working on the display of the keys in the list when called . Other methodsI've worked on other methods but are currently in function state, I'm rewriting them to fit the class structure type so they can be appended to the variable e.g myList.reverse() |
Author : @Youngestdev Update.I've written some new methods.
And Yes ! 🎉The List module has been pushed to the repo so it can be used from now on. More functionalities will be added soon. |
Another Update.The .slice() method has been added to the List module, so we can now have an instance of something like this:
But, the .slice() method doesn't support the use of one argument. If you intend to use it with one parameter, use the |
Well, I think i'll be closing the issue now. The issue will be re-opened only when another data type module is built. Cheers 🎉 |
Update on The Data Types Modules__ Double DashUsing double dash as the beginning of class variable in the simple-lang standard modules should be implored to make the variables unique and also avoid developers to create a variable identifier that will clash with identifiers in the modules Private object and blocksIn the standard modules objects and blocks that is not to be touched outside the class should be declared private to prevents data manipulation to avoid breaking the class. The private objects will not be accessible from outside the class, all the private objects and blocks can be declared with the keyword private follow by all the blocks and objects e.g
__OBJECT variableAll the classes that will be inheriting the class Object should have it primary elements declared as __OBJECT. this will make all the general blocks very effective in the Object class, simple-lang don't force implementation of abstract classes but the development should be strictly adhere to Type SafeThere should be very clear different in term of security, certainty, safe implementations between low level declaration and high level declaration with classes. A low level declaration such as
with the isString(str) condition the integrity of the parameter is checked while just str = "" does not, other method can include confirming the length of parameter and object, defining limit and types, using an internal definition of variable to be different from global variable |
Keeping this issue open is advised |
Erh cool..Keeping it open will be better.. since new additions might be included. |
Is there a dictionary implementation? I want to attempt that. |
Dictionary in what sense ?
On Jul 13, 2018 14:52, "Steve Akinyemi" <[email protected]> wrote:
Is there a dictionary implementation? I want to attempt that.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#15 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Adkrj7Un3TzbgSAx-cfi2aH7Ln2PO_FHks5uGKYNgaJpZM4Uumky>
.
|
@appcypher a dictionary implementation will be great due to it possibilities and it possible uses, |
@Youngestdev If you are familiar with hashmaps, that's what a dictionary is. It's an associative array that stores key-value pairs and can be indexed by their keys. I believe you already know what it is by now, otherwise, I can go into more details. @Thecarisma I've not had enough time to grok around the language because of work. I will take a deeper dive soon. However, I'd like to know the syntax suggestions you may have as I don't think there is a syntax for dictionary yet. Currently, I'm going with the following: map = new Map(
['name', 'James'],
['age', 45],
['gender', 'male']
)
map.get('name') # 'James'
map.put('job', 'Gardener')
map.size() # 4
map.keys() # ['name', 'age', 'gender', 'job']
map.values() # ['James', 45, 'male', 'Gardener'] |
Just figured that the above idea won't work without varargs. map = new Map([
['name', 'James'],
['age', 45],
['gender', 'male']
]) |
Okay, I get it @appcypher. It'll be great to have such feature in simple-lang as @Thecarisma said. |
@appcypher the list literal error is not intentional
that should not temper with performance and weigh on the memory as it is garbage collected after block execution Varargssensing your usage of the Map block it should accept unlimited number of parameter similar to list. That will be implemented into simple-lang after this release. we will have a parameter like
|
@Thecarisma Varargs would definitely be nice. You may notice that I've deleted the message abt nested list. I later found that it works in a different way. For a list list = [[1, 2], [3, 4]] It appears the index of the inner list starts at 1, so while list[0][1] |
Why do I feel like the index should start at 0. I thought we discussed this
@Thecarisma ?
…On Jul 14, 2018 10:10, "Steve Akinyemi" ***@***.***> wrote:
@Thecarisma <https://github.com/Thecarisma> Varargs would be definitely
be nice.
You may notice that I've deleted the message abt nested list. I later
found that it works in a different way.
For a list
list = [[1, 2], [3, 4]]
It appears the index of the inner list starts at 1, so while list[0][0]
won't work. This will.
list[0][1]
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Adkrj9W8t-UoHH14QGkdJwTSh9sFPXjYks5uGbWHgaJpZM4Uumky>
.
|
The list index definitely start from zero but and one two but it should not clash in which ever way. #instead of
list[0][1]
#use
tList = list[0]
tList[0] till error is resolved |
Well, we better try fix the error because the above method situated isn't recommended. |
Just found out that there is a dictionary data structure in Simple already.
My map impl is kinda useless unless I change it to HashMap. BTW, we need to document things more to prevent duplication of effort. |
Well. I just thought of that too @appcypher. I'll try write a list of already written modules to avoid duplication. |
@appcypher you might not need to dig deep into cryptography you can use the sha1, sha254, md5 and other hashes from the security library to hash keys |
Cool. I will look into that. |
Heyo! It's quite long here... I be trying to improve another function/method in the test = new List(arr)
test.map(arr, fn) Although I have only rough ideas yet, I'll try out them into reality.. I'll see what I can do on that and keep updating us! |
Just ensure your fork is upto date, build from master as breaking changes has been implemented |
Sure
On May 6, 2019 10:27 AM, "A Toy Soldier" <[email protected]> wrote:
Just ensure your fork is upto date, build from master as breaking changes
has been implemented
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHMSXDZQPLJJWBJLGSN35UDPT72XLANCNFSM4FF2NEZA>
.
|
Author : @Youngestdev
I'll be working on building data type modules such as List.sim and Number.sim.
Reason.
Modules will enable us carry out basic operations in data type.
Example
A list will be able to add, delete, reverse once the module is built.
Result from this ?
Well, we'll have methods that arrays ( as in JavaScript ) or Lists ( as in Python ).
example :
The text was updated successfully, but these errors were encountered: