Advertisement
juaniisuar

practica 6

Jun 16th, 2016
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.94 KB | None | 0 0
  1. ;...
  2.  
  3. (define (mapi f l)
  4.              (cond [(empty? l) '()]
  5.                    [else (cons (f (first l)) (mapi f (rest l)))]))
  6.  
  7. (define (raices L) (map sqrt L))
  8.  
  9. ;...
  10.  
  11. (define (pares L) (filter even? L))
  12.  
  13. (define (shorty Str) (if (< (string-length Str) 5) #t #f))
  14. (define (cortas L) (filter shorty L))
  15.  
  16. (define (positivos L) (filter positive? L))
  17.  
  18. ;...
  19.  
  20.  
  21. (define (check1 v1 v2) (if (and v1 v2) #t #f) )
  22. (define (todos-verdaderos L) (foldr check1 #t L))
  23.  
  24. (define (check2 v1 v2) (if (or v1 v2) #t #f) )
  25. (define (uno-verdadero L) (foldr check2 #t L))
  26.  
  27.  
  28. (define (LUL x y) (+ 1 y) )
  29. (define (cant-elementos L) (foldr LUL 0 L))
  30.  
  31. ;...
  32.  
  33. (define (prod L) (foldr * 1 L))
  34. (define (pegar L) (foldr string-append "" L))
  35.  
  36. ;...
  37.  
  38. (define (mult-pos L) (foldr * 1 (filter positive? L)))
  39. (define (sumAbs L) (foldr + 0 (map abs L)) )
  40. (define (check3 X) (if (not (negative? X)) #t #f ) )
  41. (define (raicess L) (map sqrt (filter check3 L)) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement