Skip to content

Instantly share code, notes, and snippets.

(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])))
\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]
(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))
(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)))
;;; 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/>,
(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)))))