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
(ns inf1010-oblig4.core | |
(:require [clojure.core.reducers :as r])) | |
(defn split [xs x] | |
(split-with (comp neg? #(compare % x)) xs)) | |
(defn add-sorted [xs x] | |
(let [[smaller larger] (split xs x)] | |
(reduce into [] [smaller [x] larger]))) |
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
\documentclass{standalone} | |
\usepackage{tikz} | |
\usetikzlibrary{arrows.meta, positioning, decorations.pathreplacing} | |
\pgfdeclarelayer{bg} % declare background layer | |
\pgfsetlayers{bg,main} % set the order of the layers (main is the standard % layer) | |
\begin{document} | |
\begin{tikzpicture}[>=stealth, shorten >= 5pt, node distance=4em, scale=1] | |
\tikzstyle{vertex} = [circle, scale=0.5] |
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 edge? [w1 w2] | |
(and (not= w1 w2) (= (last w1) (first w2)))) | |
(defn add-edges [m w words] | |
(let [edges (filter (partial edge? w) words)] | |
(assoc m w edges))) | |
(defn build-graph [words] | |
(reduce (fn [m w] (add-edges m w words)) {} words)) |
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
(defun clear-comint () | |
"Runs `comint-truncate-buffer' with the | |
`comint-buffer-maximum-size' set to zero." | |
(interactive) | |
(let ((comint-buffer-maximum-size 0)) | |
(comint-truncate-buffer))) | |
(add-hook 'comint-mode-hook (lambda () (local-set-key (kbd "C-l") 'clear-comint))) |
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
;;; shared-buffer.el --- Collaberative editing in Emacs. -*- lexical-binding: t -*- | |
;; Copyright (C) 2013 - 2015 Lars Tveito. | |
;; Author: Lars Tveito <larstvei@ifi.uio.no> | |
;; Version: 0.2.1 | |
;; Package: shared-buffer | |
;; Package-Requires: ((cl-lib "1.0") (websocket "1.3")) | |
;; Contains code from GNU Emacs <https://www.gnu.org/software/emacs/>, |
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
(ql:quickload "flexi-streams") | |
(defvar *words* | |
(with-open-file (stream "dict" :element-type '(unsigned-byte 8)) | |
(let ((stream (flexi-streams:make-flexi-stream | |
stream :external-format :utf-8))) | |
(loop for line = (read-line stream nil 'eof) | |
until (eq line 'eof) collect | |
(list (sort (coerce (string-downcase line) 'list) #'char<) line))))) |