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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace CSharpGym | |
{ | |
/// <summary> | |
/// Delegates (C# Programming Guide) | |
/// https://msdn.microsoft.com/en-us/library/ms173171.aspx |
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
//Submit an HTTP GET request | |
public String getHTTP(String svcURL) { | |
//HTTP objects | |
HttpRequest req = new HttpRequest(); | |
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID()); | |
req.setHeader('Content-Type', 'application/json'); | |
String domainUrl = URL.getSalesforceBaseUrl().toExternalForm(); | |
req.setEndpoint(domainUrl + svcURL); |
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
#http://regularcoder.wordpress.com/2014/03/01/python-anagrams-within-words/ | |
class AnagramChecker: | |
#Temporary list that contains the first word. We will remove matching | |
#characters from here | |
#Python doesn't insist on explicit declaration of class variables but | |
#this variable was declared for purposes of clarity | |
tempFirstWord = [] | |
def checkChar(self, charOfSecondWord): | |
if charOfSecondWord in self.tempFirstWord: |
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
(defun get-msrn-naive (x n) | |
(let ((a 16807) (m 2147483647)) | |
(mod (* | |
a | |
;Multiply either by x or recursive call | |
(if (eq n 1) | |
x | |
(get-msrn-naive x (- n 1)))) | |
m))) |
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
;XOR p q => (p V q) ^ !(p ^ q) | |
(defun xor (p q) | |
(and | |
(or p q) | |
(not (and p q)) | |
) | |
) | |
;Represent a number as a boolean list | |
(defun getbinary (n) |
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
/* | |
* Created by SharpDevelop. | |
* Date: 1/4/2014 | |
* Time: 5:15 PM | |
* | |
* | |
*/ | |
using System; | |
using System.Text; | |
using System.Collections.Generic; |
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
/* | |
* Created by SharpDevelop. | |
* Date: 8/15/2013 | |
* Time: 6:33 PM | |
* | |
* | |
*/ | |
using System; | |
using System.Collections.Generic; | |
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
/* | |
* Created by SharpDevelop. | |
* Date: 5/26/2013 | |
* Time: 4:04 PM | |
* | |
* | |
*/ | |
using System; | |
using System.Collections.Generic; |
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
/* | |
* Created by SharpDevelop. | |
* Date: 5/25/2013 | |
* Time: 3:30 PM | |
* | |
*/ | |
using System; | |
using System.IO; | |
using System.Collections.Generic; |
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
--Tells us if x is divisible by y | |
divby :: (Integral x) => x -> x -> Bool | |
divby x y = | |
(x `mod` y) == 0 | |
--Internal function that returns output for a single number | |
isfizzbuzz :: (Integral x) => x -> String | |
isfizzbuzz x | |
| divby x 3 && divby x 5 = "FizzBuzz" | |
| divby x 3 = "Fizz" |