Skip to content

Instantly share code, notes, and snippets.

@mark-d-holmberg
mark-d-holmberg / Makefile
Created March 9, 2011 18:56
convert a C++ std::string to the template type you specify
all:
g++ -Wall -g -o sstream-convert.x86 main.cpp
clean:
rm sstream-convert.x86
@mark-d-holmberg
mark-d-holmberg / .vimrc
Last active August 7, 2019 17:30
My .vimrc Config File for ViM
set nowrap
set nu
set cindent
set ts=2
set shiftwidth=2
set autowrite
hi Search ctermbg=6 guibg=LightBlue
set hlsearch
" set noexpandtab
set expandtab
@mark-d-holmberg
mark-d-holmberg / gVim _vimrc
Created August 2, 2011 22:35
gVim's .vimrc file for Windows.
nmap <C-V> "+gP
imap <C-V> <ESC><C-V>i
vmap <C-C> "+y
set nu
@mark-d-holmberg
mark-d-holmberg / eq2_prolog.txt
Created September 7, 2011 20:27
Eight Queens as a List Help (Prolog)
Mark Holmberg, Dixie State College of Utah
CS 3520, Programming Languages
7 Sept. 2011
Some help with 8-queens so you don't have to type as much.
If you want to test your 8-Queens predicate you can NOT write a test predicate
like Russ said. Although it does work, it only returns true or false NOT the
list of the proper queen locations. The following is the test case I used.
@mark-d-holmberg
mark-d-holmberg / mwgc.pl
Created September 7, 2011 21:09
The Man, The Wolf, The Goat, and The Cabbage
% See the Gist Here
% https://gist.github.com/1201748
change(e,w).
change(w,e).
move([X,X,Goat,Cabbage],wolf,[Y,Y,Goat,Cabbage]) :-
change(X,Y).
move([X,Wolf,X,Cabbage],goat,[Y,Wolf,Y,Cabbage]) :-
change(X,Y).
@mark-d-holmberg
mark-d-holmberg / mwgc_tests.txt
Created September 7, 2011 21:13
Man, Wolf, Goat, Cabbage Tests
Mark Holmberg, Dixie State College of Utah
CS 3520, Programming Languages
7 Sept. 2011
Some help with the Man, the Wolf, the Goat, and the Cabbage.
Since the solution is given on the site, but not how to invoke a solution
I searched through the slides to come up with this to actually test it
length(X,7), solution([w,w,w,w],X).
@mark-d-holmberg
mark-d-holmberg / sudoku_pretty.rb
Created September 9, 2011 02:32
How to generate Sudoku boards for the Solver
# Mark Holmberg, Dixie State College of Utah
# CS 3520, Programming Languages
# 8 Sept. 2011
# http://www.sudoku-solutions.com/
# Purpose: Generate 'unsolved' sudoku puzzles for the sudoku
# solver to solve.
# Step One: Go to the URL above and hit the 'Random' button.
# Step Two: After the board is formed hit the 'Save' button and open the
@mark-d-holmberg
mark-d-holmberg / assert.prolog
Created September 10, 2011 03:20
Asserting in Prolog
Mark Holmberg, Dixie State College of Utah
CS 3520, Programming Languages
9 Sept. 2011
Some help with the adventure game
% Lets assert some things
assert(bag(key)), assert(bag(candle)), assert(bag(sword)), assert(bag(bow)).
% do we have a candle?
bag(candle).
@mark-d-holmberg
mark-d-holmberg / clojure_quicksort.cjl
Created September 12, 2011 17:03
Clojure Quicksort and More!
//Mark Holmberg tiggers.no.tail@gmail.com
//CS350, Programming Languages
//date: Mon Sep 12 09:33:11 MDT 2011
//Clojure
//http://en.wikipedia.org/wiki/Quicksort
((fn [x] (* x x)) 5)
//calling a function with only one parameter
#(* % %)
@mark-d-holmberg
mark-d-holmberg / tail_recursion.clj
Created September 14, 2011 15:52
Tail Recursion in Clojure
Mark Holmberg, Dixie State College of Utah
CS 3520, Programming Languages
14 Sept. 2011
(defn foldl [f sofar lst]
(if (empty? lst) sofar
(foldl f(f (first lst) sofar) (rest lst))))
(defn foldr [f sofar lst]