I hereby claim:
- I am kolharsam on github.
- I am kolharsam (https://keybase.io/kolharsam) on keybase.
- I have a public key ASBjGCBJ9oW5F-QhszNQwHvt1N11lgF6DkXXQCBj0SX5PAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| #! /usr/bin/env stack | |
| -- stack --resolver lts-12.14 script | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {- | |
| This is a handy illustration of converting between five of the commonly-used | |
| string types in Haskell (String, ByteString, lazy ByteString, Text and lazy | |
| Text). |
| ;; This app was made using the template provided via leiningen. | |
| ;; use lein new compojure <project-name> to create a similar project | |
| ;; This content's of this file can directly go into `handler.clj` | |
| ;; All necessary documentation can be found in these sources: | |
| ;; https://github.com/weavejester/compojure/wiki | |
| ;; https://github.com/ring-clojure/ring/wiki | |
| (ns rest-hasura-api.handler | |
| (:require [compojure.core :refer :all] |
| const list = [1,2,3,4,5,6,7,8,9]; | |
| const inc = x => x + 1; | |
| const isOdd = x => x % 2 !== 0; | |
| console.log(list.map(inc)); | |
| console.log(list.filter(isOdd)) | |
| console.log(list.map(inc).filter(isOdd)) | |
| console.log(list.reduce((acc, val) => { | |
| if (isOdd(inc(val))) { |
| package main | |
| import "fmt" | |
| func moveZeros(numList []int) []int { | |
| j := len(numList) - 1 | |
| // immutability ftw! | |
| resList := make([]int, len(numList)) | |
| copy(resList, numList) |
| ;; Just wanted to take a different approach to using | |
| ;; logarithms or recursively dividing... | |
| ;; powers of 2, in binary, have only 1 bit as "1", so I'll look for just that! | |
| (require '[clojure.string :as str]) | |
| (defn is-power-of-2? | |
| "Returns true if n is a power of 2" | |
| [n] |
| #!/bin/sh | |
| #_( | |
| "exec" "clojure" "-Sdeps" "{:deps {org.clojure/clojurescript {:mvn/version \"1.10.520\"}}}" "$0" "$@" | |
| ) | |
| ;; running js_parser.clj "function foo(x) { var y = x + 1; }" will print: | |
| ;; [{:type :function, :name "foo", :body [{:variable-statement [{:lvalue "y", :initializer {:type :binary-op, :left "x", :operator "+", :right "1"}}]}], :params ["x"]}] | |
| (def S (atom "")) | |
| (def undo-stack (atom [])) | |
| (def redo-stack (atom [])) | |
| ;; Helpers | |
| (defn reset-stacks! | |
| "Empties both stacks" | |
| [] | |
| (reset! undo-stack []) |
Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
| ; A simple demo of monadic composition of side effects | |
| ; Program to take 3 nubers as input and print their sum. | |
| (defn read-and-add! | |
| [prev] | |
| (print "Enter a number: ") | |
| (+ prev (do (flush) | |
| (Integer/parseInt (read-line))))) | |
| (defn bind |