Skip to content

Commit

Permalink
Merge pull request #161 from cherryramatisdev/challenges/2-palindromo…
Browse files Browse the repository at this point in the history
…s/lisp/cherryramatisdev

Challenge 2 palindromo - Lisp
  • Loading branch information
lanjoni authored Oct 5, 2023
2 parents 54da11e + d0cc76a commit 6b75d6c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
23 changes: 23 additions & 0 deletions challenges/2-palindromos/lisp/cherryramatisdev/model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Submissão de Exercício

**Exercício:** 2 - Palíndromos

**Nickname:** cherryramatisdev

**Nível Técnico:** - Senior -

**Empresa:** - He4rt -

**Twitter**: <https://twitter.com/cherry_ramatis>

**Dificuldade de Resolução:** - Baixa -

**Comentários:** Consegui descobrir a existência da função `princ` que printa pro STDOUT sem as `""`.

**Como rodar o desafio**:

Use o comando abaixo:

```bash
ros -Q palindromo.lisp
```
16 changes: 16 additions & 0 deletions challenges/2-palindromos/lisp/cherryramatisdev/palindromo.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(defun palindromo? (word)
"Check if a given `word' is a palindrome"
(let* ((downcased-word (string-downcase word))
(reversed-word (reverse downcased-word)))
(string-equal downcased-word reversed-word)))

(defun print-palindromo (word)
"A function that use `'palindromo? but print the correct word to STDOUT"
(if (palindromo? word)
"true"
"false"))

(defun main (&rest args)
(if (> (length args) 0)
(loop for arg in args do (print (print-palindromo arg)))
(princ (print-palindromo (read-line)))))

0 comments on commit 6b75d6c

Please sign in to comment.