Skip to content

Instantly share code, notes, and snippets.

@llaisdy
llaisdy / matmul.ex
Created December 28, 2023 17:28
Elixir matrix multiplication with Nx.tensors
defmodule MatMul do
use ExUnit.Case
def matmul(m1, m2) do
{rows1, cols1} = m1.shape
{rows2, cols2} = m2.shape
assert cols1 == rows2
m2t = Nx.transpose(m2)
for row <- 0..rows1-1, col <- 0..cols2-1
do
%%%% Boys in the Hood
%%%% https://llaisdy.co.uk/2020/08/26/solving-a-logic-puzzle-with-clingo/
%%%% The world.
episode(1..5).
victim(friar_tuck; little_john; maid_marian; much; will_scarlet).
location(inn; dungeon; lodge; gaol; stocks).
disguise(abbot; shepherd; phantom; prince_john; washerwoman).
%% For each Episode, there is one (V,L,D) combination,
defmodule Drop do
def clown1(x) do
5 * x
end
def clown2a(x) do 5 * x end
def clown2b (x) do 5 * x end
def clown2c x do 5 * x end
$ env CC=gcc ./rebar compile
==> rdma_dist-master (compile)
Compiling c_src/rdma_drv.c
In file included from c_src/rdma_drv.c:17:0:
/usr/include/arpa/inet.h:27:1: error: unknown type name ‘__socklen_t’
typedef __socklen_t socklen_t;
^
/usr/include/arpa/inet.h:35:1: error: unknown type name ‘in_addr_t’
extern in_addr_t inet_addr (__const char *__cp) __THROW;
^
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"/></head>
<body>
<h1>Sortable Demo</h1>
<div id="demo"></div>
<div id="jsfooter">
<script src="https://fb.me/react-0.13.3.min.js"></script>
% hex tiles puzzle
% - https://chris-lamb.co.uk/posts/giants-causeway-puzzle
% - https://llaisdy.wordpress.com/2015/01/13/that-giants-causeway-puzzle-in-prolog/
:- use_module(library(clpfd)). %% for all_different/1
%% tile(Name, Colours).
% tiles from picture
@llaisdy
llaisdy / gist.erl
Last active December 17, 2015 03:49
folding functions over context
-module(gist).
-export([authenticate/3]).
authenticate(UserName, Pass, IPAddress) ->
Checks = [fun user_ok/1,
fun password_ok/1,
fun ipaddr_ok/1
],
{Result, _} = lists:foldl(
fun(_CheckFun, {{error, Reason}, _}) ->