Created
May 31, 2012 16:56
-
-
Save alcidesfp/2844735 to your computer and use it in GitHub Desktop.
Versión original en Racket de dec->hex.
This file contains hidden or 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
| ;; -*- coding: utf-8; mode: Scheme -*- | |
| #lang racket | |
| (provide dec->hex) | |
| (define (dec->hex num) | |
| (let ((base 16) | |
| (cifras-hex "0123456789ABCDEF")) | |
| (do ((cantidad num (quotient cantidad base)) | |
| (retval '() (cons (string-ref cifras-hex | |
| (remainder cantidad base)) | |
| retval))) | |
| ((= cantidad 0) | |
| (if (null? retval) "0" (list->string retval))) ))) |
Author
Author
Después de refactorizar y quitar todas las asignaciones set! quedó así
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Esta es la primera versión tal y como estaba escrita originalmente