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 <stdio.h> | |
#include <stdlib.h> | |
int main (int argc, char **argv) | |
{ | |
signed short i, min, max; | |
i = min = max = 0; | |
while (++i) { |
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 <stdio.h> | |
#define TABSTP 4 | |
/* TODO: read this string from argv, | |
to test different scenarios */ | |
char* input_str = "Something to test it"; | |
int nexttbstp (int position); | |
int printblank(int start, int end); |
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 <stdio.h> | |
#define TABSTP 4 | |
/* TODO: read this string from argv, | |
to test different scenarios */ | |
char* input_str = "Something to test it"; | |
int nexttbstp (int position); | |
int printblank(int start, int end); |
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
abs = function(x) | |
test = { | |
[true]=-x, | |
[x>0]=x, | |
[x==0]=0} | |
return test[true] | |
end | |
print (abs(-3)) -- outputs "3" |
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
t3 = {1, 4, 5, 2, 31} | |
print (t3[3]) -- will output "5" | |
t4 = {a = "foo", b = 3} | |
print (t4.a) -- will output "foo" | |
print (t4.b) -- will output "3" |
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
t1 = { a=1, b="hello" } | |
print (t1["a"]) -- outputs "1" | |
t2 = { [1<4] = "foo", [1<10] = "bar" } | |
print (t2[true]) -- outputs "bar" |
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
--[[ | |
print("hello world") | |
--]] | |
-- By adding a single hypen at the beginning of the top line, you effectively uncomment the whole block: | |
---[[ | |
print("hello world") | |
--]] |
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 eat(food) | |
print ("I eat " .. food) | |
end | |
function drink(food) | |
print ("I drink " .. food) | |
end | |
function swallow (food) | |
func = {[true] = eat, |
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 <stdio.h> | |
#include <stdlib.h> | |
int main (int argc, char** argv){ | |
fork(); | |
fprintf(stdout, "Hello World"); | |
return EXIT_SUCCESS; | |
} |
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 <stdlib.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
int main(int argc, char** argv){ | |
fork(); | |
/* The function getpid() returns the PID of the current process */ | |
fprintf(stdout, "I'm a process, my PID is: %d", getpid()); | |
return EXIT_SUCCESS; |
NewerOlder