Skip to content

Instantly share code, notes, and snippets.

View Mroik's full-sized avatar

Mroik/PositiveC Mroik

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mroik on github.
  • I am mroik (https://keybase.io/mroik) on keybase.
  • I have a public key ASBnpSDjaJtoZZWtpHb7Uh_HyAeUm3urXCdIVYvEu5nnbgo

To claim this, I am signing this object:

@Mroik
Mroik / split.c
Created February 22, 2021 23:17
split function for strings implemented in C
int split(char *string, char sep, int n_char, char ***array_values)
{
int n_values = 1;
int start = 0;
for(int x = 0; x < n_char; x++)
{
if(string[x] == sep)
n_values++;
}
@Mroik
Mroik / OOP_in_C.c
Last active January 27, 2022 00:10
This is an example of how to program with OOP paradigm in C (why would you ever do this)
#include <stdio.h>
#include <stdlib.h>
typedef int(*int_ptr)(test);
typedef struct {
int a;
int_ptr next;
} test;
int next_r(test* self)
exception NoItems
// O(n)
let reverse lst =
let rec rr lst acc =
match lst with
| [] -> acc
| x :: xs -> rr xs (x :: acc)
rr lst []
@Mroik
Mroik / exp.fsx
Created April 21, 2022 14:52
Approx e^x with taylor
let fact x =
let rec fact_r x acc =
match x with
| 1.0 -> acc
| y -> fact_r (x - 1.0) (acc * x)
fact_r x 1.0
let expo x k =
let rec expo_r x k acc =
match k with
@Mroik
Mroik / taylor.fsx
Last active April 26, 2022 20:17
Taylor series to approximate a generic function
let fact x =
let rec fact_r i acc =
match i with
| 0.0 -> acc
| a -> fact_r (i - 1.0) (acc * i)
fact_r x 1.0
let rec pwr bas ex =
match ex with
| 0 -> 1.0
@Mroik
Mroik / corruzione.elf
Last active May 25, 2022 13:11
A meme in my friend group
associazione: type.
studente: type.
*: associazione.
;: studente -> associazione -> associazione. %infix right 1 ;.
apolitica: associazione -> type.
rappresentante: studente -> type.
corrotta: associazione -> type.
contiene_rapr: associazione -> type.
instance: type.
user: type.
can_be_annoyed_at: user -> user -> type. %infix none 1 can_be_annoyed_at.
@: user -> instance -> type. %infix none 1 @.
>>: instance -> instance -> type. %infix none 1 >>.
annoyed_at: user -> user -> type. %infix none 1 annoyed_at.
</3: user -> user -> type. %infix none 1 </3.
can_enjoy: user -> user -> type. %infix none 1 can_enjoy.
enjoys: user -> user -> type. %infix none 1 enjoys.
@Mroik
Mroik / mergesort.rs
Last active September 10, 2022 13:09
use rand::Rng;
use std::cmp::Ordering;
fn main() {
let mut list: [i32; 1000] = [0; 1000];
let mut helper: [i32; 1000] = [0; 1000];
let mut rng = rand::thread_rng();
for x in 0..1000 {
list[x] = rng.gen_range(0..999);
}
@Mroik
Mroik / tree.rs
Last active September 10, 2022 23:00
use rand::Rng;
struct Node {
v: i32,
l: Option<Box<Node>>,
r: Option<Box<Node>>
}
fn make_node(v: i32) -> Node {
return Node {