Scala 10 million (with 1 million in memory):
def time[R](block: => R): R = {
val t0 = System.nanoTime()
val result = block
val t1 = System.nanoTime()
println("Elapsed time: " + (t1 - t0) / 1e9 + " s.")
result
}
// you'll need to install lazy_static crate for this code to work, so put this into your Cargo.toml: | |
// | |
// [dependencies] | |
// lazy_static = "*" | |
#[macro_use] | |
extern crate lazy_static; | |
use std::collections::{HashMap, HashSet}; | |
lazy_static! { |
import sys | |
from random import choice | |
parts = [ | |
[ | |
"Champ,", | |
"Fact:", | |
"Everybody says", | |
"Dang", |
## This script removes all docker images with name `<none>`. | |
## Typically, this frees a lot of disk space if you often use different docker images. | |
## Removal is forced, i.e. `docker rmi -f` is used. | |
{output, 0} = System.cmd("docker", ["images"]) | |
images = | |
output |> String.split("\n") |> Enum.drop(1) |> Enum.map(fn line -> | |
# since docker output is aligned by spaces, we need to do this trick here: | |
# we know that valid records in any column will not have repeated spaces, |
use std::fmt; | |
use std::fmt::{Display, Formatter}; | |
struct S { | |
x: i64, | |
} | |
fn define_impl() { | |
impl Display for S { | |
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { |
use std::fmt; | |
use std::fmt::{Display, Formatter}; | |
struct S { | |
x: i64, | |
} | |
fn define_impl() { | |
impl Display for S { | |
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { |
{:user {:plugins [[cider/cider-nrepl "0.20.0"] | |
[mvxcvi/whidbey "2.1.1"]] | |
:middleware [whidbey.plugin/repl-pprint] | |
:dependencies [[org.clojure/tools.nrepl "0.2.13"] | |
[cljfmt "0.5.7"] | |
[com.bhauman/rebel-readline-cljs "0.1.4"]] | |
:aliases {"rebl" ["trampoline" "run" "-m" "rebel-readline-cljs.main"]}}} |
defmodule F do | |
@moduledoc """ | |
Defines a macro that converts recursive 2-tuples to 3-tuples with the third | |
element being a sum of the first 2. Supports variable interpolation at any level | |
of nesting. | |
""" | |
defmacro f(quoted) do | |
inner(quoted) | |
end |
defmodule Foo do | |
defmacro select(columns) when is_list(columns) do | |
# in macro context we replace all `^foo` forms with `foo` | |
columns = Macro.postwalk(columns, &interpolate/1) | |
IO.inspect(columns, label: :columns_after_interpolate) | |
# we unquote in the caller context, and map atoms to Columns after all | |
# `^foo` were replaced with `foo` | |
quote do |
Scala 10 million (with 1 million in memory):
def time[R](block: => R): R = {
val t0 = System.nanoTime()
val result = block
val t1 = System.nanoTime()
println("Elapsed time: " + (t1 - t0) / 1e9 + " s.")
result
}
defmodule Chess do | |
alias Chess.{Board, Player, Move, Interaction} | |
def play() do | |
play(Board.init(), Player.first_turn(), 0) | |
end | |
def play(board, player, turn) do | |
move = Interaction.read_move(player) |