Find Jobs
Hire Freelancers

Scheme Small task

$30-250 USD

Cerrado
Publicado hace alrededor de 3 años

$30-250 USD

Pagado a la entrega
;; ===== Procedural Abstraction ===== ;; Using the instructions provided on LEARN, give a defintion for fold-tree (define fold-tree '() ) ;; Using the instructions provided on LEARN, give a defintion for depth (define depth '() ) ;; Using the instructions provided on LEARN, give a defintion for count (define count '() ) Procedural Abstraction Consider the following five functions: (define add (lambda (sexpr) (cond ((null? sexpr) 0) ((pair? sexpr) (+ (add (car sexpr)) (add (cdr sexpr)))) (else sexpr)))) (define copy (lambda (sexpr) (cond ((null? sexpr) ’()) ((pair? sexpr) (cons (copy (car sexpr)) (copy (cdr sexpr)))) (else sexpr)))) (define size (lambda (sexpr) (cond ((null? sexpr) 0) ((pair? sexpr) (+ (size (car sexpr)) (size (cdr sexpr)))) (else 1)))) (define depth (lambda (sexpr) (cond ((null? sexpr) 0) ((pair? sexpr) (add1 (max (depth (car sexpr)) (depth (cdr sexpr))))) (else 0)))) (define count (lambda (pred sexpr) (cond ((null? sexpr) 0) ((pair? sexpr) (+ (count pred (car sexpr)) (count pred (cdr sexpr)))) ((pred sexpr) 1) (else 0)))) These functions can be used as follows: > (add '((1 . 2) . (3 . 4))) 10 > (copy '(a b c d)) (a b c d) > (size '(a b c d)) 4 > (depth '((1 . 2) . (3 . 4))) 2 > (count even? '((1 . 2) . (3 . 4))) 2 Demonstrate your mastery of procedural abstraction by defining a function fold-tree which abstracts the pattern of the five functions. When you are finished, use fold-tree to defined Give a definition of depth. Give a definition of count. Hint: You may not be able to make count fit the pattern because it has an extra case and takes an extra argument. You can curry count and use count-c to implement count. You can use a helper function to combine the last two cases and rewrite count using the helper-function. These two tricks will make it look more like the others. Fold Tree The function fold-tree can be used to define new functions. For example, > (flatten-tree '((1 . 2) . (3 . 4))) (1 2 3 4) > (flatten-tree '((a) ((b)) (((c))))) (a b c) > (map-tree add1 '((1 . 2) . (3 . 4))) ((2 . 3) . (4 . 5)) > (map-tree even '((1 . 2) . (3 . 4))) ((#f . #t) . (#f . #t)) Demonstrate your ability to use the fold-tree abstraction by using it to Define flatten-tree. Define map-tree.
ID del proyecto: 29706903

Información sobre el proyecto

1 propuesta
Proyecto remoto
Activo hace 3 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
1 freelancer está ofertando un promedio de $200 USD por este trabajo
Avatar del usuario
hello , i just read task discription and it really jumped out on me , i can deliver it perfectly . i am a developer having 5 years of experience , although I am a new reelancer and being a new freelancer doesn't describe my tech skills just give me a chance I will give my 100% and will provide a neat and nice solution. just message me the timings when we can talk . Best Regards, Rohit Angira
$200 USD en 7 días
5,0 (3 comentarios)
3,0
3,0

Sobre este cliente

Bandera de UNITED STATES
albuquerque, United States
0,0
0
Forma de pago verificada
Miembro desde dic 6, 2019

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.