View MUPL - Made Up Programming Language
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
;; Programming Languages, Homework 5 | |
#lang racket | |
(provide (all-defined-out)) ;; so we can put tests in a second file | |
;; definition of structures for MUPL programs - Do NOT change | |
(struct var (string) #:transparent) ;; a variable, e.g., (var "foo") | |
(struct int (num) #:transparent) ;; a constant number, e.g., (int 17) | |
(struct add (e1 e2) #:transparent) ;; add two expressions | |
(struct ifgreater (e1 e2 e3 e4) #:transparent) ;; if e1 > e2 then e3 else e4 |
View transducerfun.clj
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
(require '[clojure.core.async :as a]) | |
(def xform (comp (map inc) | |
(filter even?) | |
(dedupe) | |
(flatmap range) | |
(partition-all 3) | |
(partition-by #(< (apply + %) 7)) | |
(flatmap flatten) | |
(random-sample 1.0) |
View for-loop.fish
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
function for-loop | |
set list \ | |
"foo" \ | |
"bar" \ | |
"zee" | |
for item in $list | |
echo "item: $item" | |
end | |
end |
View utils.cljc
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
(defn in? | |
"true if seq contains elm" | |
[seq elm] | |
(boolean (some (fn [e] (= elm e)) seq))) |
View do_exec.py
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 python | |
from subprocess import Popen, PIPE | |
import operator | |
import os | |
import re | |
import datetime | |
import time | |
from functools import reduce | |
from pathlib import Path |
View for-loop.sh
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 bash | |
# Debugging | |
# set -x | |
# Stop on error | |
set -e | |
# Exit if variables are not set (recommended) | |
set –u | |
tstp() { |
View list-ppa
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 bash | |
# get all the PPAs installed on a system ready to share for reininstall | |
for APT in `find /etc/apt/ -name \*.list`; do | |
# list found files - helps in case of: '... public key is not available: NO_PUBKEY' | |
echo $APT | |
grep -o "^deb http://ppa.launchpad.net/[a-z0-9\-]\+/[a-z0-9\-]\+" $APT | while read ENTRY ; do | |
USER=`echo $ENTRY | cut -d/ -f4` | |
PPA=`echo $ENTRY | cut -d/ -f5` | |
echo sudo apt-add-repository ppa:$USER/$PPA |
View logging.sh
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 bash | |
# Debugging | |
# set -x | |
# Stop on error | |
set -e | |
# Exit if variables are not set (recommended) | |
set –u | |
logfile=file.log |
View cobol-mode.el
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
;;; cobol-mode.el --- Mode for editing COBOL code -*- lexical-binding: t; -*- | |
;; Copyright (C) 2013-2015 Edward Hart | |
;; Author: Edward Hart <edward.dan.hart@gmail.com> | |
;; Maintainer: Edward Hart | |
;; Version: 0 | |
;; Created: 9 November 2013 | |
;; Keywords: languages |
View loop-recur.clj
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
(loop [r 0 | |
break false] | |
(if-not break | |
(if (< r 5) | |
(do | |
(println "Expensive calculation of r:" r) | |
(recur (inc r) false)) | |
(do | |
(println "Breaking the loop at:" r) | |
(recur r true))))) |
NewerOlder