lib/HelloWorldFizzBuzz/sqlite.rb in HelloWorldFizzBuzz-1.0.0 vs lib/HelloWorldFizzBuzz/sqlite.rb in HelloWorldFizzBuzz-1.1.0
- old
+ new
@@ -25,55 +25,56 @@
=begin
Example entry:
@posts.insert(language: 'programinglanguage',
- helloworld: " helloworld example
-",
- fizzbuzz: " fizzbuzz example
-",)
+ helloworld: ' helloworld example
+',
+ fizzbuzz: ' fizzbuzz example
+',)
=end
### A
@posts.insert(language: 'ada',
- helloworld: "with Text_IO;
-procedure Hello_World is
- begin
- Text_IO.Put_line('Hello World!');
- end Hello_World;
-",
- fizzbuzz: "procedure FizzBuzz( X : Natural ) is
+ helloworld: 'with Ada.Text_IO;
+
+procedure Hello is
+begin
+ Ada.Text_IO.Put_Line("Hello, world!");
+end Hello;
+',
+ fizzbuzz: 'procedure FizzBuzz( X : Natural ) is
function FB( I : Integer ) return String is
- (if I mod 15 = 0 then 'FizzBuzz'
- elsif I mod 5 = 0 then 'Buzz''
- elsif I mod 3 = 0 then 'Fizz'
+ (if I mod 15 = 0 then "FizzBuzz"
+ elsif I mod 5 = 0 then "Buzz"
+ elsif I mod 3 = 0 then "Fizz"
else ""
);
begin
for I in 1..X loop
Ada.Integer_Text_IO.Put ( I );
Ada.Text_IO.Put ( ' ' & FB(I) );
Ada.Text_IO.New_Line;
end loop;
-end FizzBuzz;")
+end FizzBuzz;')
### B
@posts.insert(language: 'basic',
- helloworld: "
-10 PRINT 'Hello World!'
+ helloworld: '
+10 PRINT "Hello World!"
20 GOTO 10
-",
- fizzbuzz: "
+',
+ fizzbuzz: '
10 DEF FN M(N) = ((A / N) - INT (A / N)) * N
20 FOR A = 1 TO 100
30 LET O$ = ""
-40 IF FN M(3) = 0 THEN O$ = 'FIZZ'
-50 IF FN M(5) = 0 THEN O$ = O$ + 'BUZZ'
+40 IF FN M(3) = 0 THEN O$ = "FIZZ"
+50 IF FN M(5) = 0 THEN O$ = O$ + "BUZZ"
60 IF O$ = "" THEN O$ = STR$ (A)
70 PRINT O$
80 NEXT A
-")
+')
### C
@posts.insert(language: 'C',
helloworld: "#include<stdio.h>
main()
@@ -81,73 +82,73 @@
printf('Hello World');
}
",
- fizzbuzz: "#include <stdio.h>
+ fizzbuzz: '#include <stdio.h>
int main(void)
{
int i;
for(i=1; i<=100; ++i)
{
if (i % 3 == 0)
- printf('Fizz');
+ printf("Fizz");
if (i % 5 == 0)
- printf('Buzz');
+ printf("Buzz");
if ((i % 3 != 0) && (i % 5 != 0))
- printf('number=%d', i);
- printf('\n');
+ printf("number=%d", i);
+ printf("\n");
}
return 0;
}
-")
+')
### D
@posts.insert(language: 'dart',
- helloworld: "void main() {
- print('hello world!');
+ helloworld: 'void main() {
+ print("hello world!");
}
-",
- fizzbuzz: "void main() {
+',
+ fizzbuzz: 'void main() {
for (var i = 1; i <= 100; i ++) {
if (i % 15 == 0) {
- print('FizzBuzz');
+ print("FizzBuzz");
}
else if (i % 3 == 0) {
- print('Fizz');
+ print("Fizz");
}
else if (i % 5 == 0) {
- print('Buzz');
+ print("Buzz");
}
else {
print(i);
}
}
-}")
+}')
### E
@posts.insert(language: 'erlang',
- helloworld: "-module(hello).
+ helloworld: '-module(hello).
-export([hello_world/0]).
- hello_world() -> io:fwrite('hello, world\n').
-",
- fizzbuzz: "-module(fizzbuzz).
+ hello_world() -> io:fwrite("hello, world\n").
+',
+ fizzbuzz: '-module(fizzbuzz).
-export([fizzbuzz/1]).
--define(MOD_THREE, 'fizz').
--define(MOD_FIVE, 'buzz').
+-define(MOD_THREE, "fizz").
+-define(MOD_FIVE, "buzz").
% Helper function to map fizzbuzz across a sequence of numbers
fizzbuzz(To) ->
lists:map(fun nt/1, lists:seq(1, To)).
% initiate the number transform for a Number
nt(Number) ->
number_transform(Number, []).
-% transform the number to either nothing or 'fizz' or 'buzz' or 'fizzbuzz'
+% transform the number to either nothing or "fizz" or "buzz" or "fizzbuzz"
%% NOTE: This style of fizzbuzz allows arbitrary matching
%% e.g. add bazz for number where Number rem 7 == 0
number_transform(0, Words) ->
lists:flatten(lists:reverse(Words));
number_transform(Number, Words) when Number rem 3 == 0 ->
@@ -163,12 +164,30 @@
number_transform(Number, []) ->
Number;
number_transform(Number, Words) ->
Number,
lists:flatten(lists:reverse(Words)).
-")
+')
### F
+@posts.insert(language: 'F#',
+ helloworld: 'let _ = printf "Hello world"',
+ fizzbuzz: 'let fizzbuzz x =
+ if x % 3 = 0 && x % 5 = 0 then
+ (*[omit:print "fizz" ans "buzz"]*)printfn "fizzbuzz"(*[/omit]*)
+ elif x % 3 = 0 then
+ (*[omit:print "fizz"]*)printfn "fizz"(*[/omit]*)
+ elif x % 5 = 0 then
+ (*[omit:print "buzz"]*)printfn "buzz"(*[/omit]*)
+ else
+ (*[omit:print number]*)printfn "%d" x(*[/omit]*)
+
+let fizzbuzz_loop n =
+ List.iter fizzbuzz [1 .. n]
+
+
+fizzbuzz_loop 100;;
+')
### G
### H
### I