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
;1; | |
(sort #(> %2 %1) '( 1 4 2 )) | |
;2; | |
(def x 5 ) | |
(let [x 2] (print x)) ; x 5 local scope | |
(binding [ x 2] ( print x )) ; x=> global scope | |
;3; | |
(defn makeaddr [n] #(+ % n)) |
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 sqrt) | |
(defn abs [n] | |
(if (< n 0) | |
(* -1 n)n)) | |
(defn goodenough? [guess prevguess] | |
(> 0.0000001 ( abs (- guess prevguess) ) )) | |
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 class IterableQuery { | |
public static Where from(Iterable originalCollection) { | |
return new Where( Iterables.transform(originalCollection, IterableQuery.SAME())); | |
} | |
private static Function SAME() { | |
return new Function(){ | |
public T apply(T arg0) { | |
return arg0; |
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
WeeklyActivityRecorder weeklyActivities = new WeeklyActivityRecorder (); | |
weeklyActivities .AddActivity( new Activity{Day = DayOfWeek.Monday , Activity = "Lawn Moving" }); | |
weeklyActivities .AddActivity( new Activity{Day = DayOfWeek.Tuesday , Activity = "Cooking" }); |
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
WeeklyActivityRecorder weeklyActivities = new WeeklyActivityRecorder () .WithActivities( Monday => "Lawn Moving",Tuesday => "Cooking"); |
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 WeeklyActivityRecorder WithActivities(this WeeklyActivityRecorder recorder, params Expression<Func<DayOfWeek, string>>[] activities) | |
{ | |
foreach( var activity in activities ) | |
{ | |
LambdaExpression expression = activity; | |
ConstantExpression activity= expression.Body as ConstantExpression; | |
DayOfWeek day = expression.Parameters[0]; | |
recorder.AddActivity(new Activity {DayOfWeek = day , Activity = activity}); | |
} | |
return recorder ; |
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
protected IList<T> _FindByProperty(string propertyName , object value) | |
{ | |
return _hibernateTemplate.Execute( | |
session => session.CreateCriteria(typeof(T)). | |
Add(Expression.Eq(propertyName, value)).List()) | |
.Cast<T>().ToList(); | |
} |
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
IList<User> costCenters = _FindByProperty( user=> user.Name, "surya"); |
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
jQuery.extend(jQuery.expr[':'], { | |
classStartsWith: function(a, i, m){ | |
var classes = $(a).attr("className").split(" ") | |
var found = false; | |
for (var i = 0; i < classes.length; i++) { | |
if (classes[i].startsWith(m[3])) { | |
found = true; | |
break; | |
} | |
} |
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
$('input:classStartsWith('highlight')') |
OlderNewer