This file contains hidden or 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Fri Jun 12 18:29:33 2015 | |
@author: chema | |
""" | |
from concurrent.futures import ( | |
Future, ProcessPoolExecutor, ThreadPoolExecutor, TimeoutError, as_completed) | |
from itertools import islice |
This file contains hidden or 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
def birthday(n: Int) = { | |
1 - (0 until n).map(1 - BigDecimal(_) / 365).product | |
} | |
assert(birthday(23) == BigDecimal("0.5072972343239854072254172283370325")) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |