One day, I started wondering if it would be possible to parse Clojure namespace forms and generate a dependency graph of the various namespaces used in a real-world Clojure project. While that was the original motivation, I ended up down the Raku grammar rabbit hole, and had an enjoyable time learning how to use them. I'm glad you're joining me in reliving that journey.
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::strbuf::StrBuf; | |
fn reverse_sentence(sentence: ~str) -> ~str { | |
let mut buffer = StrBuf::new(); | |
let mut string_vector: Vec<~str> = Vec::new(); | |
for word in sentence.split(' ') { | |
string_vector.push(word.to_owned()); | |
} |
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<iostream> | |
#include<vector> | |
using std::vector; | |
using std::cout; | |
using std::endl; | |
using std::cin; | |
int main(void) |
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
open Graph | |
module Vertex = struct | |
type t = string | |
let compare = Pervasives.compare | |
let hash = Hashtbl.hash | |
let equal = (=) | |
end | |
module Edge = struct |
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 <map> | |
#include <tuple> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
template<typename KeyType> | |
std::pair<KeyType, std::size_t> most_frequent_element(std::vector<KeyType> elts) { | |
std::map<KeyType, std::size_t> frequency_table; | |
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
(* http://www.problemotd.com/problem/party-hat/ *) | |
open Core.Std;; | |
open Sequence;; | |
let print_party_hat height = | |
let hat_width line_no = | |
2*line_no + 1 in | |
let print_char_n char n = | |
String.make n char |
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 <vector> | |
#include <cassert> | |
#include <iostream> | |
#include <forward_list> | |
using std::cout; | |
using std::cin; | |
using std::endl; | |
using std::vector; |
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
~ | |
❯ timestamp-from-ms 1585725108000 | |
2020-04-01T07:11:48Z | |
~ | |
❯ timestamp-from-ms 1585725108000 +5:30 | |
2020-04-01T12:41:48+05:30 | |
~ | |
❯ timestamp-from-ms 1585725108000 -5:30 | |
2020-04-01T01:41:48-05:30 | |
~ |
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
#!/usr/bin/env raku | |
use v6.d; | |
#use Grammar::Tracer; | |
grammar RealisticNs { | |
token TOP { <realistic-ns> } | |
token realistic-ns { <lparen> | |
<ns-keyword> <.ws> <ns-name> <.ws> |
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
#!/usr/bin/env raku | |
use v6.d; | |
use Grammar::Tracer; | |
grammar EmptyLispForm { | |
token TOP { <lparen> <rparen> } | |
token lparen { '(' } | |
token rparen { ')' } |
OlderNewer