Skip to content

Instantly share code, notes, and snippets.

@philipschwarz
philipschwarz / print-diamond.clj
Created December 3, 2014 00:20
First stab at Clojure print-diamond
(defn print-diamond [letter]
(let [alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
position-of (fn [letter] (inc (- (int letter) (int \A))))
number-of-letters (position-of letter)
dashes (fn [n] (repeat n \-))
fixed-text-for (fn [letter] (concat (dashes (dec (position-of letter))) (list letter)))
template (map fixed-text-for (take number-of-letters alphabet))
pad-with-trailing-dashes (fn [index line] (concat line (dashes (dec (- number-of-letters index)))))
top-right-quadrant (map-indexed pad-with-trailing-dashes template)
top-left-quadrant (map reverse (map rest (take number-of-letters top-right-quadrant)))

Keybase proof

I hereby claim:

  • I am philipschwarz on github.
  • I am philip_schwarz (https://keybase.io/philip_schwarz) on keybase.
  • I have a public key whose fingerprint is B0D0 6715 3B2D 4C62 D0DE CC12 97DC 056B 8C5B 068B

To claim this, I am signing this object:

public ArrayList eseguiAnalisi() {
ArrayList listaSegnalazioni = new ArrayList();
List domande = null;
Domanda domanda = null;
List risposte = null;
DAOReques req = new DAOReques();
DAOArea ar = new DAOArea();
ar.setIdQuestionario(getIdQuestionario());
if item.name != 'Aged Brie' && item.name != 'Backstage passes to a TAFKAL80ETC concert'
if item.quality > 0
if item.name != 'Sulfuras, Hand of Ragnaros'
item.quality -= 1
end
end
else
if item.quality < 50
item.quality += 1
if item.name == 'Backstage passes to a TAFKAL80ETC concert'
@philipschwarz
philipschwarz / gist:1325176
Created October 29, 2011 22:27
multiply-by-two
(define (multiply-by-two list)
(if (null? list)
nil
(cons (* 2 (car list))
(cdr list))))
@philipschwarz
philipschwarz / Main.java
Created October 29, 2011 21:40
Tail-recursive multiplyByTwo
public class Main
{
public static void main(String[] args)
{
List list = List.EMPTY_LIST;
int n = 6000;
while(n > 0)
list = list.cons(n--);
@philipschwarz
philipschwarz / Main.java
Created October 29, 2011 20:45
Recursive multiplyByTwo
public class Main
{
public static void main(String[] args)
{
List list = List.EMPTY_LIST;
int n = 6000;
while(n > 0)
list = list.cons(n--);
public class List
{
public static final List EMPTY_LIST = new List();
public List(int n, List rest)
{
this.n = n;
this.rest = rest;
}
@philipschwarz
philipschwarz / gist:1241180
Created September 25, 2011 21:31
Separating use from construction - After
public class BusinessObject {
public void actionMethod() {
// Other things
//No Change!
Servicec myServiceObject = Service.getInstance();
myServiceObject.doService();
// Other things
}
}
@philipschwarz
philipschwarz / gist:1241175
Created September 25, 2011 21:27
Separating use from construction - Before
public class BusinessObject {
public void actionMethod() {
// Other things
Service myServiceObject = Service.getInstance();
myServiceObject.doService();
// Other things
}
}
class Service {