Mix.install([
{:nx, "~> 0.6"},
{:exla, "~> 0.6"}
])
Nx.global_default_backend(EXLA.Backend)
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
defmodule(Math.Foo, [{:do, [@foo(3), def(foo(b), [{:do, @foo + b}]), def(add(b), [{:do, @foo + b}])]}]); alias(Math.Foo); IO.puts(Foo.add(2)) |
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
{ | |
description = "elixir"; | |
inputs = { | |
flake-parts.url = "github:hercules-ci/flake-parts"; | |
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
}; | |
outputs = inputs@{ flake-parts, ... }: | |
flake-parts.lib.mkFlake { inherit inputs; } { |
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
# Change this according to your device | |
################ | |
# Variables | |
################ | |
# Date and time | |
date_and_week=$(date "+%Y/%m/%d (w%V)") | |
current_time=$(date "+%H:%M:%S") | |
############# |
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
@reserved_characters ~c":/?#[]@!$&'()*+,;=" | |
@spec is_char_reserved(byte) :: boolean | |
defguard is_char_reserved(character) when character in @reserved_characters |
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
MIX_ENV=prod mix run bench.exs | |
Operating System: Linux | |
CPU Information: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz | |
Number of Available Cores: 8 | |
Available memory: 15.30 GB | |
Elixir 1.14.3 | |
Erlang 25.3 | |
Benchmark suite executing with the following configuration: | |
warmup: 2 s |
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
// Generated by Futhark 0.25.0 (prerelease - include info below when reporting bugs) | |
// git: 6a2e6e1 (Sun Apr 30 19:03:19 2023 +0200) [modified] | |
// We need to define _GNU_SOURCE before | |
// _any_ headers files are imported to get | |
// the usage statistics of a thread (i.e. have RUSAGE_THREAD) on GNU/Linux | |
// https://manpages.courier-mta.org/htmlman2/getrusage.2.html | |
#ifndef _GNU_SOURCE // Avoid possible double-definition warning. | |
#define _GNU_SOURCE | |
#endif |
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
def cap [n] (xs: [n]f64) = | |
map (\x -> x / f64.maximum xs) xs | |
def comb' [n] (delay: i64) (intensity: f64) (xs: [n]f64): [n]f64 = | |
loop xs = copy xs for i in delay..<n do | |
let xs[i] = xs[i] + intensity * xs[i - delay] | |
in xs | |
entry comb delay intensity = map (cap <-< comb' delay intensity) |
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
-- # Generating audio with literate Futhark | |
-- | |
-- Sound is vibrations in the air that are picked up by our ears. Vibrations | |
-- can be described using sine-curves. Computers are ultimately discrete in | |
-- nature, so in order to produce sound we have to approximate sine-curves using | |
-- sampling. Let's see how that works in practice. | |
-- We start by defining some global variables that we're going to use. | |
-- First, the volume which we wish to output at. |
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
.PHONY: all | |
all: | |
futhark c futmusic.fut | |
rm -f output.wav | |
echo "" | ./futmusic -b | tail -c+18 | head -c-1 | ffmpeg -f s8 -i - output.wav | |
mpv output.wav |
NewerOlder