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
import Control.Monad.State.Lazy | |
import Text.Printf | |
aprox :: Double -> State Double Double | |
aprox t = state (\y -> | |
let add = (t - x) * (1.0 - y) / (10.0 - x) | |
x = 10.0 ** y | |
in (t - x, y + add)) | |
combine_x_times :: (Monad m) => Int -> m a -> m a |
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
use std::thread; | |
use std::sync::mpsc::{self, TryRecvError}; | |
use std::io; | |
use std::time::Instant; | |
struct CircularIter<T> where T: Copy { | |
data: Vec<T>, | |
index: usize, | |
} |
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
use std::io::{self, Write}; | |
fn main() { | |
loop { | |
print!("repl>"); | |
io::stdout().flush().expect("Could not flush stdout"); | |
let mut line = String::new(); | |
io::stdin().read_line(&mut line).expect("Could not read from stdin"); |
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
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
char *replace_substring_in_string(char *str, char *from, char *to) | |
{ | |
char *result; | |
unsigned int str_len, from_len, to_len; | |
str_len = strlen(str); |
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
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
char *replace_substring_in_string(char *str, char *from, char *to) | |
{ | |
char *result; | |
unsigned int str_len, from_len, to_len; | |
str_len = strlen(str); |