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
// for instance, this TS function | |
import fetch from "node-fetch"; | |
const getData = async (url: string): Promise<any | null> => { | |
try { | |
const response = await fetch(url); | |
const json = await response.json(); | |
return json; | |
} catch (error) { |
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
The Haskell functions I am trying to translate: | |
promptLine :: String -> IO String | |
promptLine msg = do | |
putStr msg | |
hFlush stdout | |
getLine | |
input :: Read a => String -> (a -> Bool) -> IO a | |
input msg validator = do |
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
// Requires at least C++17 | |
#include <filesystem> | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
int main() { | |
// Path is relative to executable. | |
std::filesystem::path filePath = "./out.txt"; |
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
// Try it out on https://godbolt.org/ with Clang with concepts! | |
// GitHub insists on this having a tab size of 8 even though I told it to use 4, even after deleting and reuploading this. :-( | |
// Please excuse the massive indents! | |
#include <iostream> | |
#include <type_traits> | |
namespace MyProject { | |
template <typename T> |
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
///! Version: C++17 | |
#include <algorithm> // for std::reverse() | |
#include <cstdint> // int64_t | |
#include <filesystem> // std::filesystem::path | |
#include <fstream> // std::ifstream, std::ofstream | |
#include <iostream> // the usual console I/O stuff | |
#include <sstream> // istringstream for parsing a string, see split() below | |
#include <string> // std::getline(), std::stol() | |
#include <vector> |