This file contains 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
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater) | |
where | |
lesser = filter (< p) xs | |
greater = filter (>= p) xs | |
main = do print(quicksort [4,3,2,1]) |
This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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 GenericRepository<T> : Repository, IRepository<T> | |
where T : class { | |
public GenericRepository(DbContext db) : base(db) { } | |
internal DbSet<T> _table | |
{ | |
get | |
{ |
This file contains 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
/// <summary> | |
/// Resizes the image for compression | |
/// </summary> | |
/// <param name="img"></param> | |
/// <param name="maxWidth"></param> | |
/// <param name="maxHeight"></param> | |
/// <returns></returns> | |
private static Image ResizeImage(Image img, int maxWidth, int maxHeight) { | |
if (img.Height < maxHeight && img.Width < maxWidth) return img; | |
using (img) { |
This file contains 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
for (var i = 0; i <= 5; i++) { | |
for (var j = 0; j <= 5; i++) { | |
for (var k = 0; k <= 5; i++) { | |
//TODO: insert horrible codes here... | |
} | |
} | |
} |
This file contains 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
JumpHere: | |
int lat, lng, frequency; | |
if (true) | |
{ | |
goto myHorribleCode; | |
} | |
else | |
{ | |
goto JumpHere; |
This file contains 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
function quicksort(arr) { | |
if (arr.length < 2) { | |
return arr; | |
} else { | |
var pivot = arr[0]; | |
var less = []; | |
var greater = []; | |
var result = []; | |
for (var i = 1; i < arr.length; i++) { //skip first array |
This file contains 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
def quicksort(array): | |
if len(array) < 2: | |
return array #Base case: arrays with 0 or 1 element are already “sorted.” | |
else: | |
pivot = array[0] #Recursive case | |
less = [i for i in array[1:] if i <= pivot] #Sub-array of all the elements less than the pivot | |
greater = [i for i in array[1:] if i > pivot] #Sub-array of all the elements greater than the pivot | |
result = quicksort(less) + [pivot] + quicksort(greater) | |
print(result) | |
return result |
This file contains 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
def quicksort(array): | |
if len(array) < 2: | |
return array #Base case: arrays with 0 or 1 element are already “sorted.” | |
else: | |
pivot = array[0] #Recursive case | |
less = [i for i in array[1:] if i <= pivot] #Sub-array of all the elements less than the pivot | |
greater = [i for i in array[1:] if i > pivot] #Sub-array of all the elements greater than the pivot | |
result = quicksort(less) + [pivot] + quicksort(greater) | |
print(result) | |
return result |
This file contains 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
def quicksort(array): | |
if len(array) < 2: | |
return array #Base case: arrays with 0 or 1 element are already “sorted.” | |
else: | |
pivot = array[0] #Recursive case | |
less = [i for i in array[1:] if i <= pivot] #Sub-array of all the elements less than the pivot | |
greater = [i for i in array[1:] if i > pivot] #Sub-array of all the elements greater than the pivot | |
result = quicksort(less) + [pivot] + quicksort(greater) | |
print(result) | |
return result |
OlderNewer