CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 09:47:12 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=cf53c6fd8afa9458ced2d35f3cde167555e6ee6e6a7a9dedbf4ff4fdc87d58bba%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22_70gJCOrqTnIkGjJi9kQ7s3z382FDtgs%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cd6f45dfefa8b0-BLR
Solucion examen 07 de DIc - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Solución primer punto
- */
- import scala.annotation.tailrec
- object Punto1 {
- def zipf(f:(Int,Int)=>Int, lstA:List[Int], lstB:List[Int]):List[Int] = {
- @tailrec
- def zipfAux(f:(Int,Int)=>Int, lstA:List[Int], lstB:List[Int], acc:List[Int]):List[Int] = {
- if (lstA.isEmpty || lstB.isEmpty) acc
- else zipfAux(f, lstA.tail, lstB.tail, acc :+ f(lstA.head, lstB.head))
- }
- zipfAux(f, lstA, lstB, List())
- }
- def main(args: Array[String]): Unit = {
- println(zipf((x,y)=>x+y, List(1,2,3), List(2,4,6)))
- println(zipf((x,y)=>x*y, List(1,2,3), List(2,4,6)))
- }
- }
- /**
- * Punto 2 examen opcional
- */
- object Punto2 {
- type Arbol = List[Any]
- def path(arb:Arbol, x:Int):List[String] = {
- arb match {
- case Nil => Nil
- case List(v,izq,der) => {
- if (x < v.asInstanceOf[Int]) "izq"::path(izq.asInstanceOf[List[Any]],x)
- else if (x > v.asInstanceOf[Int]) "der"::path(der.asInstanceOf[List[Any]],x)
- else Nil //Tambien puede ser case _
- }
- case _ => Nil //Warning
- }
- }
- def main(args: Array[String]): Unit = {
- val a = List(4,List(2, List(1, List(), List()), List(3, List(), List())),List(6, List(), List()))
- println(path(a, 4))
- println(path(a, 3))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ 4
JavaScript | 7 sec ago | 0.24 KB
-
⭐⭐Exchange Exploit⭐⭐ Y
JavaScript | 12 sec ago | 0.24 KB
-
⭐✅ MAKE $2000 INSTANTLY ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 15 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ T
JavaScript | 18 sec ago | 0.24 KB
-
⭐⭐⭐Make $15OO in 2O minutesV G⭐⭐
Java | 23 sec ago | 0.10 KB
-
✅⭐ Make huge profits on trading ⭐⭐ 6
JavaScript | 23 sec ago | 0.24 KB
-
⭐ Free Crypto Method ✅ NEVER SEEN BEFORE ⭐⭐⭐
JavaScript | 25 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ✅ NEVER SEEN...
JavaScript | 33 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand