CoddityTeam / movaicode

Concours mensuel du Pire Développeur de France
123 stars 10 forks source link

Participation en ArkScript #55

Closed SuperFola closed 2 years ago

SuperFola commented 3 years ago

Hello!

Je me suis dit que ça pourrait être marrant de faire ça avec un langage pas du tout connu, du coup voici:

###
# @brief Returns a + 1
# @param a a value
# @author me
###
(let inc (fun (a) (+ 1 a)))

###
# @brief Returns a - 1
# @param a a value
# @author me
###
(let dec (fun (a) (- a 1)))

###
# @brief Run on an array
# @param array the array
# @param func a function
# @author me
###
(let for-each (fun (array func) {
    (mut i 0)
    (let max (len array))
    (while (< i max) {
        (func (@ array i))
        (set i (inc i))
    })
}))

###
# @brief a string
###
(let string (input "string> "))

###
# @brief length
###
(let length (len string))

###
# @brief a number
###
(mut i (dec length))

###
# @brief a list (not an array but referred to as an array sometimes)
###
(mut new_as_list [])

(while (>= i 0) {
    (mut char (@ string i))
    (set new_as_list (append new_as_list char))
    (set i (dec i))
})

###
# @brief a string
###
(mut new_as_str "")

###
# @brief a global variable used for global purposes
###
(mut global 0)

(for-each new_as_list (fun (element) {
    (let index (+ global (list:find (list:slice new_as_list global length 1) element)))
    (set global (inc global))
    (assert (= (@ new_as_list index) element) "The elements are not equal, aborting!")
    (set new_as_str (+ new_as_str (@ new_as_list index)))
}))

(print new_as_str)

Pour tester: https://arkscript-lang.github.io/tutorials/building.html#from-a-release (ou possibilité de build from source mais ça peut être long)

louismarslen commented 3 years ago

Cher Alexandre, j'ai le plaisir et l'honneur de vous annoncer que vous n'avez PAS gagné le concours MOVAI CODE. Ce qui fait de vous un EKSSELAN Codeur.

SPOILER : j'espère qu'on aura le plaisir de recevoir votre participation à l'episode 2 du MOVAI CODE (stay tuned).

Bravo toutefois pour votre belle contribution 😊

louismarslen commented 2 years ago

Je fais un peu de ménage dans les issues -> d'ailleurs go participer à l'édition 5