-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from cherryramatisdev/challenges/2-palindromo…
…s/lisp/cherryramatisdev Challenge 2 palindromo - Lisp
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
16
challenges/2-palindromos/lisp/cherryramatisdev/palindromo.lisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))))) |