Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; The first three lines of this file were inserted by DrRacket. They record metadata
- ;; about the language level of this file in a form that our tools can easily process.
- #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)))
- ;LCC 250: Pereyra Julieta, Benitez Emanuel.
- ;
- ; 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.
- ; Entonces: String Numéro -> String
- (define (string-insert texto n) ; Definiendo la función "define (identificador argumento1 argumento2)"
- (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"
- (substring texto n (string-length texto)) ; esta es la parte desde n hasta la ultima letra
- ); fin de string-append
- )
- (string-insert "Programación" 8) ; llamando a la función con los argumentos que sean
- ;ejercicio 8 practica 2:
- ;
- ; Diseñe la función string-remove-last, que recibe una cadena y devuelve la misma cadena sin el último carácter.
- ; String -> String
- (define (string-remove-last texto) ;definiendo la función
- (
- substring texto 0 (- (string-length texto) 1)
- );substring desde la letra 0 hasta la ultima letra restando uno
- )
- (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