Example program
GuidoDipietro opened this issue · comments
So I finally got to write a small program in CheLang. This calculates every perfect number from 1 to whatever you choose as an upper limit.
This uses 'dividido' as an array index access operator.
# I'm not sure why the % operator is not present in CheLang, so I just defined this function
definime divide(numero,coso)
agarra por enUnaDeEsas es 1 hasta (numero ma 1) tonce
ponele que (coso por enUnaDeEsas) anda por numero tonce
tirame 1
hastaaca
hastaaca
tirame 0
hastaaca
# Returns [Number of divisors] + [All divisors < num]
definime dividimeSiTeLaBancas(numero)
che messi es []
che cero es 0
agarra por chabon es 1 hasta numero tonce
ponele que divide(numero, chabon) tonce
che cero es cero ma 1
Agregale(messi, chabon)
hastaaca
hastaaca
tirame [cero] ma messi
hastaaca
# Example: dividimeSiTeLaBancas(14) -> [3,1,2,7]
# Similar to sum() in Python, but since I can't loop through an array without an 'agarra por' and I need the length,
# I had to store such length in the array itself (first element). I tried multiple returns and returning a tuple
# but that didn't work. Maybe a suggestion of a feature to add some day?
definime vamoTodosJuntos(laBarraBrava)
che todos es 0
agarra por laspelotas es 1 hasta (laBarraBrava dividido 0 ma 1) tonce
che todos es todos ma (laBarraBrava dividido laspelotas)
hastaaca
tirame todos
hastaaca
# Checks if a number meets the condition of 'perfect', a.k.a. 'bokita'
definime esNumeroBokita(numero)
ponele que vamoTodosJuntos(dividimeSiTeLaBancas(numero)) anda por numero tonce tirame 1 aLosumo tirame 0
hastaaca
# Ahora se pudre todo acá viste # Printing stuff
# Ode to Joy and Quetepasa in Argentino
Cuchame("Cheamigo esto va a tardar un rato viste no es porque este mal hecho")
Cuchame("son asi los numerobokita tardan en encontrarse, ademas viste que no tenemo")
Cuchame("todavia eso de operador resto % y longitud de una lista esas cosas viste no")
Cuchame("son bien argentas, bien criollas papa, bien de aca, esas son para lo giles ustede")
Cuchame("que usan esa' cosas para gatos que no se la bancan como nosotro asi que tomatela si te va lento el programa")
Cuchame("\n a y los tilde tampoco me andan y me la rrebanco")
che elInfinito es 10000
agarra por Argentina es 1 hasta elInfinito tonce
ponele que esNumeroBokita(Argentina) tonce Cuchame(Argentina)
hastaaca
I halted the execution rather quickly after I finished coding it because querido, tengo un examen mañana y no sé qué hago haciendo esto, tengo que dormir, but it should work fine to find the 3rd and 4th bokita numbers (496 and 8128). The 5th one is too big and takes a bunch of computation so don't expect to get it calculated.
I will probably do more of these things because la cuarentena inspira a la demencia.
Atte., Guido Dipietro
Ninos()
As a side note: the documentation wrongly states the operator "anda por" as "andaPor".
Wow. Man you are a bit crazy hahahahaha. Thanks for all.
First of all, with the function "TaLargo(list)" you can get the length of the lists... Maybe i must documentate the functions better...
The % operator is coming! I really dont use it a lot so even i didnt realize that isnt in CheLang. Maybe i can add it in today release.
About the program, you are really crazy. I really awesomed hahahahaha. Please, when you have time (study, man, dont use your time in this things close a exam.), please send a PR with the new sintaxys ( [n] list access AND USE THE LEN FUNCTION (is there for something. For your health.)) in the examples folder, so anyone interested in the project can see it :)
Again, thanks a lot for all.
PD1: Thanks for the documentation tip.
PD2: Wait and upgrate to todays release please.
I will make a pull request with the tidied-up program :) I really didn't notice the TaLargo() function, pucha.
Will eagerly be waiting for today's release!