View complex.lua
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
--[[ | |
-- | |
-- *** Complex numbers for Lua *** | |
-- | |
--]] | |
-- Module "cmath" ... mathematic functions for complex numbers | |
module("cmath", package.seeall) |
View gist:3599125
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
v = "global" | |
do | |
print(v) -- "global" | |
local v = "local" | |
print(v) -- "local", of course | |
v = nil | |
print(v) -- nil, not "global" | |
collectgarbage("collect") | |
print(v) -- still nil | |
print (_G.v) -- of course "global" |
View gist:3652275
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
#include <iostream> | |
int main() { | |
int a = 1; int b = 2; | |
if ((bool)a != (bool)b) | |
std::cout << "a xor b -> true" << std::endl; | |
else | |
std::cout << "a xor b -> false" << std::endl; | |
return 0; | |
} |
View fizzbuzz.hs
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
fizzbuzz = [f n | n <- [1..]] | |
where | |
f x | |
| x `mod` 15 == 0 = "Fizz Buzz" | |
| x `mod` 5 == 0 = "Buzz" | |
| x `mod` 3 == 0 = "Fizz" | |
| otherwise = show (fromIntegral x) | |
main = do print (take 60 fizzbuzz) |
View test2038.c
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
#include <time.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main () { | |
time_t time_num[5] = {(time_t)0x00000000, (time_t)0x7fffffff, (time_t)0x80000000, (time_t)0xffffffff,}; | |
struct tm* parsed_time; unsigned int i; | |
printf("sizeof(time_t) is %d.\n", sizeof(time_t)); | |
for (i = 0; i < 4; i++) { | |
parsed_time = gmtime(&(time_num[i])); |
View d_copy.lua
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 clone (t) -- deep-copy a table | |
if type(t) ~= "table" then return t end | |
local meta = getmetatable(t) | |
local target = {} | |
for k, v in pairs(t) do | |
if type(v) == "table" then | |
target[k] = clone(v) | |
else | |
target[k] = v | |
end |
View matrix.hpp
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
#ifndef MATRIX_HPP | |
#define MATRIX_HPP | |
#include <array> | |
#include <initializer_list> | |
#define MTXTMP template <typename T, unsigned int rows, unsigned int cols> | |
/* Matrix class template */ | |
MTXTMP class matrix { |
View gist:4069788
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
#include <wchar.h> | |
#include <stdlib.h> | |
#include <locale.h> | |
int main() { | |
char* syslocale = getenv("LANG"); | |
const wchar_t teststr[] = | |
L"僕と契約して、" | |
L"プログラマになってよ!"; | |
setlocale(LC_ALL, syslocale); |
View 1_wrong.cpp
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
#include <iostream> | |
class Parent { | |
protected: | |
static const int val = 1; | |
public: | |
virtual int getval() {return val;} | |
}; | |
class Child : public Parent { |
View ConstTest1.java
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
class Parent { | |
static final int Val = 1; | |
public int getval() { | |
return Val; | |
} | |
} | |
class Child extends Parent { | |
static final int Val = 2; | |
} |
OlderNewer