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
// definition | |
var f = function(x){ return x*2;}; | |
// evaluation | |
var f = function(x) x * 2; |
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
// definition | |
var f = function(x){ return x*2;}; | |
// evaluation | |
var f = function(x) x * 2; |
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
// Definition | |
public interface Lambda<A,V> { | |
V call(A a); | |
} | |
// Evaluation | |
public class LambdaTest extends Object { | |
public static void main(String argv[]) { | |
Lambda<String, Integer> lambda=new Lambda<String, Integer>() { | |
public Integer call(String s) { |
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 java.util.*; | |
public static List<Integer> generatePrimes(int max) | |
{ | |
List<Integer> primes = new ArrayList<Integer>(); | |
OUTERLOOP: | |
for (int i = 2; i <= max; i++) { | |
for (Integer p : primes) | |
if (i % p == 0) | |
continue OUTERLOOP; |
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
isPrime n = all ((/= 0) . (mod n)) (takeWhile (\ x -> x*x <= n) primes) | |
primes = 2 : filter isPrime [3..] |
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
def prime_number(n): | |
n = int(n) | |
primelist=[] | |
markedlist=[False]*(n+1) | |
for i in range(2,n+1): | |
if not markedlist[i]: | |
primelist.append(i) | |
for m in range(i**2, n+1, i): | |
markedlist[m] = True | |
return primelist |
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
def prime_number(max) | |
arr = (2..max).to_a | |
(2..Math::sqrt(max)).each do |i| | |
arr.delete_if {|a|a % i == 0 && a!=i} | |
end | |
arr | |
end | |
# generate | |
# puts prime_number(20) |
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
sudo env ARCHFLAGS="-arch x86_64" gem install pg |
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
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config |
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
sudo env ARCHFLAGS="-arch x86_64" gem install pg |