This file contains hidden or 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
(let [revenu 50000 | |
tranches [ [0 6011 0.] [6011 11991 0.055] [11991 26631 0.14] [26631 71397 0.3] [71397 151200 0.41]]] | |
(reduce | |
(fn [total [tmin tmax coeff]] | |
(let [m-in-tranche (- (min tmax revenu) tmin)] | |
(+ total (max 0 (* m-in-tranche coeff))))) | |
0 | |
tranches)) |
This file contains hidden or 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 euler-clj.core | |
:use [clojure.test]) | |
;; problem 1 | |
(with-test | |
(defn multiple-of-3-and-5 | |
"Find the sum of all the multiple of 3 and 5 below `limit`" | |
[limit] |
This file contains hidden or 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 to-scala-list [& vals] | |
(reduce | |
#(.apply scala.collection.immutable.$colon$colon$/MODULE$ %2 %1) | |
(scala.collection.immutable.Nil$/MODULE$) | |
(map to-jmhc-tile vals))) |
This file contains hidden or 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 minus [v1 v2] | |
"substract 2 vectors, v2 must be a subset of v1" | |
(reduce (fn [acc v] | |
(let [index (.indexOf acc v)] | |
(into (subvec acc 0 index) (subvec acc (inc index))))) v1 v2)) | |
(minus [:c :a :b :b :a :a :b] [:a :a :b :a]) ; [:c :b :b] |
This file contains hidden or 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
;; Anything you type in here will be executed | |
;; immediately with the results shown on the | |
;; right. | |
(use 'clojure.test) | |
(with-test | |
(defn extract-scheme | |
"extract scheme from url" |
This file contains hidden or 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
import fr.pmu.commons.spring.SpringBuilder; | |
import org.junit.*; | |
import org.junit.Test; | |
import org.springframework.beans.factory.config.AutowireCapableBeanFactory; | |
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.scheduling.annotation.Async; | |
import org.springframework.scheduling.annotation.EnableAsync; | |
import org.springframework.scheduling.annotation.EnableScheduling; | |
import org.springframework.stereotype.Service; |
This file contains hidden or 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
var myNamespace = (function () { | |
var myPrivateVar, myPrivateMethod; | |
// A private counter variable | |
myPrivateVar = 0; | |
// A private function which logs any arguments | |
myPrivateMethod = function( foo ) { | |
console.log( foo ); |
This file contains hidden or 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
http://www.opensourcery.co.za/2009/04/19/to-amqp-or-to-xmpp-that-is-the-question/ |
This file contains hidden or 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
Novels to read : | |
boris Vian - Et on tuera tous les affreux | |
akutagawa |
This file contains hidden or 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
public static String removeNonNumerics(String text) { | |
//remove everything except + - and digits | |
String num = text.replaceAll("[^-+\\.\\d]", ""); | |
if (num.length() > 0) { | |
//remove + and - in middle of the string | |
num = num.charAt(0) + num.substring(1).replaceAll("[-+]", ""); | |
//remove extra . (keep the first) |