This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S scala-cli shebang | |
//> using scala "3.1.0" | |
//> using lib "org.scala-lang.modules::scala-parallel-collections:1.0.4" | |
import scala.collection.parallel.CollectionConverters._ | |
def fact(n: BigInt) = | |
(n to 1 by -1).par.product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
from functools import partial | |
from collections import Counter | |
from itertools import cycle | |
from typing import Iterable | |
# única función random que se permite usar | |
rand5 = partial(randint, 1, 5) | |
# yapf: disable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
======= [% page.basename %] ======= | |
//Creado el [% strftime("%Y-%m-%d") %]// | |
TODO: @_revisar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
======= [% page.basename %] ======= | |
//Creado el [% strftime("%Y-%m-%d") %]// | |
TODO: @_revisar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a new Dotty project | |
sbt new lampepfl/dotty.g8 | |
# create a dotty project that cross compiles with scala 2 | |
sbt new lampepfl/dotty-cross.g8 | |
# start a dotty reply from within your sbt project | |
$ sbt | |
> console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<iframe height="400px" frameborder="0" style="width: 100%" src="https://embed.scalafiddle.io/embed?sfid=HiIQqkL/11&theme=dark&layout=v50"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function zipWith<T, R, S>(as: T[], bs: R[], conv: (a: T, b: R) => S): S[] { | |
return as.map((a, i) => conv(a, bs[i])); | |
} | |
function zip<T, R>(as: T[], bs: R[]) { | |
return zipWith(as, bs, (a, b) => [a, b]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package types | |
object Math { | |
import annotation.implicitNotFound | |
@implicitNotFound("No member of type class NumberLike in scope for ${T}") | |
trait NumberLike[T] { | |
def plus(x: T, y: T): T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1.Write your own definition of scanr, first using recursion, and then using foldr. | |
-- Do the same for scanl first using recursion then foldl. | |
import Prelude hiding (scanl, scanr) | |
scanr :: (a -> b -> b) -> b -> [a] -> [b] | |
scanr _ acc [] = [acc] | |
scanr f acc (x:xs) = f x (head qs) : qs | |
where qs = scanr f acc xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TypePractice where | |
data Nat = Zero | |
| Succ Nat | |
deriving Show | |
zero = Zero | |
one = Succ zero | |
two = Succ one | |
three = Succ two |