Skip to content

Instantly share code, notes, and snippets.

pragma solidity ^0.5.4;
contract MailApplication {
struct Mail {
string message;
address sender;
}
Mail[] private allMail;
@Zambito1
Zambito1 / matrix_multiplication.go
Created October 21, 2018 22:50
Concurrent Matrix Multiplication Go
package main
import (
"fmt"
"strings"
"sync"
)
func main() {
@Zambito1
Zambito1 / MultipleReceive.exs
Created July 23, 2018 02:13
Demonstration of multiple receive blocks in a single Elixir process
defmodule MultipleReceive do
def myProc do
IO.puts "Func starting: "
receive do
:first -> IO.puts "Received first message!"
end
receive do
:second -> IO.puts "Received second message!"
end
@Zambito1
Zambito1 / bouncing_counter.exs
Created July 2, 2018 16:32
Creates two processes that will bounce back and forth to count up to the input value
defmodule BouncingCounter do
def even(max, main_pid) do
receive do
{:inc, odd_pid, n} when n <= max ->
IO.puts("EVEN: Count currently at #{n}")
send(odd_pid, {:inc, self(), n + 1})
even(max, main_pid)
{:inc, even_pid, n} when n > max ->
@Zambito1
Zambito1 / BaseConverter.hs
Created June 25, 2018 04:46
Converting number bases using Haskell
import Data.List
import Data.Maybe
digits = ['0'.. '9'] ++ ['A'.. 'Z'] ++ ['a'.. 'z']
fromBase10 :: Int -> Int -> String
fromBase10 0 _ = ""
fromBase10 number base
| base > 0 = fromBase10 (number `div` base) base ++ [digits !! (number `mod` base)]
| otherwise = error "Invalid base"