Skip to content

Instantly share code, notes, and snippets.

TranslationUnitDecl 0x6845b8 <<invalid sloc>> <invalid sloc>
|-TypedefDecl 0x684e20 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
| `-BuiltinType 0x684b80 '__int128'
|-TypedefDecl 0x684e90 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
| `-BuiltinType 0x684ba0 'unsigned __int128'
|-TypedefDecl 0x685208 <<invalid sloc>> <invalid sloc> implicit __NSConstantString '__NSConstantString_tag'
| `-RecordType 0x684f80 '__NSConstantString_tag'
| `-CXXRecord 0x684ee8 '__NSConstantString_tag'
|-TypedefDecl 0x6852a0 <<invalid sloc>> <invalid sloc> implicit __builtin_ms_va_list 'char *'
| `-PointerType 0x685260 'char *'
use std::future::Future;
use tokio;
async fn foo(a: &i32, b: i32, c: i32) -> i32 {
a + b + c
}
async fn generic_fn<'a, F, Fut>(f: F, a: &'a i32) -> i32
where
use std::future::Future;
use tokio;
async fn foo<'a, 'b>(a: &'a i32, b: &'b i32, c: &'b i32) -> i32 {
a + b + c
}
async fn generic_fn<F, Fut>(f: F, a: &i32) -> i32
where
F: Fn(&i32, &i32, &i32) -> Fut,
#include <iostream>
int* getIntP(bool return_null) {
if (return_null) return nullptr;
return new int(3);
}
int main(int argc, char** argv) {
if(int* i1 = getIntP(true)) {
std::cout << *i1 << std::endl;
@rcythr
rcythr / Lambda.hs
Last active June 2, 2020 02:17
A Lambda Calculus Interpreter implemented in Haskell. The only dependency is the readline library because without it, the REPL is pure pain and suffering.
{-
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@rcythr
rcythr / Parity.hs
Created May 23, 2020 13:25
Computes 64bit parity of the given file.
module Main where
import Control.Monad
import qualified Data.ByteString as BS
import qualified Data.ByteString.Unsafe as BS
import Data.Word
import Data.Bits
import Foreign.C.String
import Foreign.Ptr
import Foreign.Storable
module Main where
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Bits
import qualified Data.ByteString as BS
import Data.Word
import System.Environment (getArgs)
@rcythr
rcythr / Philosophers.hs
Last active May 18, 2020 12:31
An implementation of the dining philosopher problem with STM in Haskell. ( see: https://en.wikipedia.org/wiki/Dining_philosophers_problem )
module Main where
import Control.Concurrent
import Control.Concurrent.STM (STM, atomically, retry)
import Control.Concurrent.STM.TVar (TVar, newTVarIO, modifyTVar', readTVar, writeTVar)
import Control.Concurrent.STM.TMVar (TMVar, newTMVarIO, takeTMVar, putTMVar)
import Control.Monad (when, forM)
import Data.Array
import System.IO (hFlush, stdout)
import System.Random
@rcythr
rcythr / gist:fa6b2abcfb173db1b5b3
Last active August 29, 2015 14:15
A simple concept of a language to implement.
import "other_functions.texc"
fun foo(a, b, \theta in reals, N in integers) -> reals =
\sum_{i=0}^{N} ( \sin(\theta) + a^i + b^i )
fun foorec(a, b, \theta in reals, N in integers) -> reals =
if N < 0 then
return 0
else
\sin(\theta) + a^N + b^N + foorec(a, b, \theta, N-1)
class BufferIterator
{
private BlockingCollection<byte[]> queue;
private byte[] cur_msg = null;
private int cur_msg_index;
public BufferIterator(BlockingCollection<byte[]> queue)
{
this.queue = queue;
}