Advertisement
Guest User

Untitled

a guest
Apr 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 1.56 KB | None | 0 0
  1. ;; The first three lines of this file were inserted by DrRacket. They record metadata
  2. ;; about the language level of this file in a form that our tools can easily process.
  3. #reader(lib "htdp-beginner-reader.ss" "lang")((modname |Ejercicio 6 y 8|) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
  4. ;LCC 250: Pereyra Julieta, Benitez Emanuel.
  5. ;
  6. ; Ejercicio 6 : Diseñe la función string-insert, que consume un string y un número i e inserta "-" en la posición i-ésima del string.
  7. ; Entonces: String Numéro -> String
  8. (define (string-insert texto n) ; Definiendo la función "define (identificador argumento1 argumento2)"
  9.   (string-append (substring texto 0 n) "-" ; string-append "(texto desde 0 hasta el numero n)" "guión" "texto desde n hasta donde termina el string"
  10.                  (substring texto n (string-length texto)) ; esta es la parte desde n hasta la ultima letra
  11.                  ); fin de string-append
  12. )
  13.  
  14.  
  15. (string-insert "Programación" 8) ; llamando a la función con los argumentos que sean
  16.  
  17.  
  18.  
  19.  
  20.  
  21. ;ejercicio 8 practica 2:
  22. ;
  23. ; Diseñe la función string-remove-last, que recibe una cadena y devuelve la misma cadena sin el último carácter.
  24. ; String -> String
  25. (define (string-remove-last texto) ;definiendo la función
  26.    (
  27.     substring texto 0 (- (string-length texto) 1)              
  28.   );substring desde la letra 0 hasta la ultima letra restando uno
  29. )
  30.  
  31. (string-remove-last "Programar"); llamando a la función y este tiene que eliminar el ultimo caracter, en este caso r.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement