calling a subroutine in scheme -
i'm trying call subroutine function on scheme have far.
(define (main) (display "ingrese un parametro: ") (define x (read-line)) (newline) (display "ingrese una posicion: ") (define dig (read)) (newline) (if (string? x) (begin (if (number? dig) (begin ;(vababa x dig))) <---calling subrutine this subroutine im trying call
define (vababa x1 dig1) (define (string-pad-right x dig1)) (define b (string-pad-left x dig1)) (define z (string-append b)) z )
but not returning nothing.. please tell me im doing wrong.
in vababa using unbound variable x. perhaps meant x1? it's not allowed use define in procedure bodies evaluates values based on previous ones.
(define (vababa x1 dig1) (define (string-pad-right x dig1)) ; x not exist anywhere (define b (string-pad-left x dig1)) ; x not exist anywhere (define z (string-append b)) ; , b not exist yet z) ; , b exists won't there since `string-append` didn't string arguments you can 1 of:
(define (vababa x1 dig1) (string-append (string-pad-right x1 dig1) ; replaced x x1 (string-pad-left x1 dig1))) ; replaced x x1 (define (vababa x1 dig1) (define (string-pad-right x1 dig1)) ; replaced x x1 (define b (string-pad-left x1 dig1)) ; replaced x x1 ;; in body , b exists (string-append b)) (define (vababa x1 dig1) (let ((a (string-pad-right x1 dig1)) ; replaced x x1 (b (string-pad-left x1 dig1))) ; replaced x x1 (string-append b))) (define (vababa x1 dig1) (let* ((a (string-pad-right x1 dig1)) ; replaced x x1 (b (string-pad-left x1 dig1)) ; replaced x x1 (z (string-append b))) z))