Skip to content

Instantly share code, notes, and snippets.

View manudatta's full-sized avatar

Manu Datta manudatta

  • Singapore
View GitHub Profile
;pg 102. Ex 3.22.c
(defn myfun [x y] (list (list x) y))
(myfun 'alpha 'beta)
;.d
(defn firstp? [ e collection] (= e (first collection)))--clojure uses ? instead of p for predicate (lisp convention)
(firstp? 'foo '(foo bar baz))
(firstp? 'boing '(foo bar baz)) -- clojure has false instead of nil
;.e
(defn mid-add1 [sentence] (list (first sentence) (+ 1 (second sentence)) (last sentence)))
(mid-add1 '(take 2 cookies))
@manudatta
manudatta / bubblesort.mips.s
Created December 14, 2012 08:34
Bubble sort in MIPS assembly.
# Copyright 2002 Manu Datta (gmail.com ID Manu dot Datta)
# All rights reserved
.data
msg1: .asciiz "\nEnter integer values followed by return (-1 terminates input): \n"
msg2: .asciiz ","
msg3: .asciiz "Bubble Sort"
msg4: .asciiz "#########pass#########"
msg5: .asciiz "\n"
msg6: .asciiz "\nNumber list has been sorted\n"
@manudatta
manudatta / topologicalsort.mips.s
Created December 14, 2012 06:08
Topological sort in MIPS assembly language. Tested in SPIM simulator.
# Copyright 2002 Manu Datta
# All rights reserved
.data
adjMatrix: .space 450
.align 2
count: .space 225
#msg1: .asciiz "Error in toplogical sort:\n"
#msg2: .asciiz "graph contanis a cycle\n"
msg3: .asciiz "Vertex : "