nilac 0.0.4.3.4 → 0.0.4.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,48 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ var _i,_j,decimalToBinary;
4
+
5
+ //This is Nila's decimal to Binary converter. It's awesome
6
+
7
+ decimalToBinary = function(input_num) {
8
+ var remainder, storage, numsplit, inputnum, decimalplaces, calc, decans;
9
+ remainder = "";
10
+ storage = [];
11
+ if (!((input_num.indexOf(".") === -1))) {
12
+ numsplit = input_num.split(".");
13
+ inputnum = Number(numsplit[0]);
14
+ decimalplaces = parseFloat("0." + numsplit[1]);
15
+ } else {
16
+ inputnum = Number(input_num);
17
+ decimalplaces = [];
18
+ }
19
+ while (inputnum >= 1) {
20
+ console.log("2 | " + (inputnum) + " " + (remainder));
21
+ remainder = inputnum%2;
22
+ inputnum = (inputnum-remainder)/2;
23
+ storage.push(remainder);
24
+ }
25
+ storage.reverse();
26
+ if (decimalplaces.toString().length > 0) {
27
+ storage.push(".");
28
+ }
29
+ calc = null;
30
+ decans = null;
31
+ for (_i = 0, _j = decimalplaces.toString().length-2; _i < _j; _i += 1) {
32
+ calc = decimalplaces * 2;
33
+ decans = calc.toString()[0];
34
+ decimalplaces = parseFloat("0." + (calc.toString().slice(2)));
35
+ storage.push(Number(decans));
36
+ };
37
+ return storage;
38
+ };
39
+
40
+ process.stdin.resume();
41
+
42
+ process.stdin.setEncoding('utf8');
43
+
44
+ process.stdin.on('data',function(chunk) {
45
+ process.stdout.write("Answer: " + (decimalToBinary(chunk).join("")) + " \n\n");
46
+ });
47
+
48
+ }).call(this);
@@ -0,0 +1,65 @@
1
+ #This is Nila's decimal to Binary converter. It's awesome
2
+
3
+ def decimalToBinary(input_num)
4
+
5
+ remainder = ""
6
+
7
+ storage = []
8
+
9
+ unless (input_num.indexOf(".") == -1)
10
+
11
+ numsplit = input_num.split(".")
12
+
13
+ inputnum = Number(numsplit[0])
14
+
15
+ decimalplaces = parseFloat("0." + numsplit[1])
16
+
17
+ else
18
+
19
+ inputnum = Number(input_num)
20
+
21
+ decimalplaces = []
22
+
23
+ end
24
+
25
+ while inputnum >= 1
26
+ puts "2 | #{inputnum} #{remainder}"
27
+ remainder = inputnum%2
28
+ inputnum = (inputnum-remainder)/2
29
+ storage << remainder
30
+ end
31
+
32
+ storage.reverse
33
+
34
+ if decimalplaces.to_s.length > 0
35
+
36
+ storage << "."
37
+
38
+ end
39
+
40
+ calc = nil
41
+
42
+ decans = nil
43
+
44
+ (decimalplaces.to_s.length-2).times do
45
+
46
+ calc = decimalplaces * 2
47
+
48
+ decans = calc.to_s[0];
49
+
50
+ decimalplaces = parseFloat("0.#{calc.to_s[2..last]}")
51
+
52
+ storage << Number(decans)
53
+
54
+ end
55
+
56
+ return storage
57
+
58
+ end
59
+
60
+ process.stdin.resume();
61
+ process.stdin.setEncoding('utf8');
62
+ process.stdin.on 'data', do |chunk|
63
+ print "Answer: #{decimalToBinary(chunk).join("")} \n\n"
64
+ end
65
+
data/lib/nilac/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nilac
2
- VERSION = "0.0.4.3.4"
2
+ VERSION = "0.0.4.3.6"
3
3
  end
@@ -0,0 +1,11 @@
1
+ Feature: This feature brings Ruby's native String and Array methods to Nila.
2
+ Scenario: Input function with several native Ruby methods
3
+ Given the input file "ruby_methods.nila"
4
+ When the ~compiler is run
5
+ The output file must be "ruby_methods.js"
6
+ The output file must equal "correct_ruby_methods.js"
7
+
8
+ Configurations:
9
+
10
+ ~compiler => src/nilac.rb
11
+ :v $cliusage => ruby :v --compile $file
@@ -4,7 +4,7 @@ start = numbers[0..2]
4
4
 
5
5
  middle = numbers[3...6]
6
6
 
7
- last = numbers[6..end]
7
+ last = numbers[6..last]
8
8
 
9
9
  copy = numbers.dup
10
10
 
@@ -14,7 +14,7 @@ name = "Adhithya Rajasekaran"
14
14
 
15
15
  first_name = name[0..7]
16
16
 
17
- second_name = name[9..end]
17
+ second_name = name[9..last]
18
18
 
19
19
  name_copy = name.dup
20
20
 
@@ -1,6 +1,6 @@
1
1
  //Written using Nila. Visit http://adhithyan15.github.io/nila
2
2
  (function() {
3
- var container, fill, liquid;
3
+ var fill;
4
4
 
5
5
  // This is a demo of default parameters
6
6
 
@@ -1,6 +1,6 @@
1
1
  //Written using Nila. Visit http://adhithyan15.github.io/nila
2
2
  (function() {
3
- var _ref1, count, current_val, first_name, last_name, name_split, name_split1, name_split2, next_val, parse_name;
3
+ var _ref1, count, current_val, first_name, last_name, next_val, parse_name;
4
4
 
5
5
  // This file demonstrates multiple variable initialization
6
6
 
@@ -26,10 +26,4 @@
26
26
 
27
27
  count = _ref1[2];
28
28
 
29
- _ref1 = ["Adhithya Rajasekaran".split((" "),1),"Adhithya Rajasekaran".split(" ",2)];
30
-
31
- name_split1 = _ref1[0];
32
-
33
- name_split2 = _ref1[1];
34
-
35
29
  }).call(this);
@@ -1,6 +1,6 @@
1
1
  //Written using Nila. Visit http://adhithyan15.github.io/nila
2
2
  (function() {
3
- var _ref1, first_name, last_name, parse_name, parsed_name, test_method;
3
+ var parse_name, parsed_name, test_method;
4
4
 
5
5
  // This method demonstrates multiple return values
6
6
 
@@ -1,7 +1,6 @@
1
1
  //Written using Nila. Visit http://adhithyan15.github.io/nila
2
2
  (function() {
3
3
  if (visitor_present) {
4
- //This file is for demonstration purpose. It doesn't really achieve anything
5
4
  if (active || happy) {
6
5
  console.log("Hello Wonderful Visitor!");
7
6
  } else if (idle && not_engaged) {
@@ -2,8 +2,6 @@
2
2
  (function() {
3
3
  var counter;
4
4
 
5
- // This file will demonstrate Nila's while loops
6
-
7
5
  counter = 1;
8
6
 
9
7
  while (counter < 11) {
@@ -0,0 +1,45 @@
1
+ //Written using Nila. Visit http://adhithyan15.github.io/nila
2
+ (function() {
3
+ var jsonp, jsonprint, name, parsejson;
4
+
5
+ name = "Adhithya Rajasekaran ".replace(/\s+$/g,"");
6
+
7
+ console.log(name);
8
+
9
+ name = " Adhithya Rajasekaran".replace(/^\s+/g,"");
10
+
11
+ console.log(name);
12
+
13
+ name = "Adhithya Rajasekaran".split(" ");
14
+
15
+ console.log(name);
16
+
17
+ name = " Adhithya Rajasekaran ".replace(/^\s+|\s+$/g,'');
18
+
19
+ console.log(name);
20
+
21
+ name = "Adhithya,Rajasekaran".split(",");
22
+
23
+ console.log(name);
24
+
25
+ name = ["Adhithya","Rajasekaran"].join();
26
+
27
+ console.log(name);
28
+
29
+ jsonprint = function(inputjson) {
30
+ return console.log(inputjson);
31
+ };
32
+
33
+ jsonp = function(inputjson) {
34
+ return console.log(inputjson);
35
+ };
36
+
37
+ parsejson = function(inputtext) {
38
+ return inputtext.split("{");
39
+ };
40
+
41
+ parsejson(jsonprint("{message:Hello World!}"));
42
+
43
+ jsonprint("{message:Hello World!}");
44
+
45
+ }).call(this);
@@ -13,5 +13,3 @@ first_name,last_name = parse_name("Adhithya Rajasekaran")
13
13
  puts first_name + " " + last_name
14
14
 
15
15
  current_val, next_val, count = 0, 1, 1
16
-
17
- name_split1,name_split2 = "Adhithya Rajasekaran".split((" "),1),"Adhithya Rajasekaran".split(" ",2)
@@ -1,7 +1,5 @@
1
1
  if visitor_present?
2
2
 
3
- #This file is for demonstration purpose. It doesn't really achieve anything
4
-
5
3
  if active? or happy?
6
4
 
7
5
  puts "Hello Wonderful Visitor!"
@@ -1,5 +1,3 @@
1
- # This file will demonstrate Nila's while loops
2
-
3
1
  counter = 1
4
2
  while counter < 11
5
3
  puts counter
@@ -21,4 +21,26 @@ puts name
21
21
 
22
22
  name = ["Adhithya","Rajasekaran"].join
23
23
 
24
- puts name
24
+ puts name
25
+
26
+ def jsonprint(inputjson)
27
+
28
+ puts inputjson
29
+
30
+ end
31
+
32
+ def jsonp(inputjson)
33
+
34
+ puts inputjson
35
+
36
+ end
37
+
38
+ def parsejson(inputtext)
39
+
40
+ inputtext.split("{")
41
+
42
+ end
43
+
44
+ parsejson jsonprint "{message:Hello World!}"
45
+
46
+ jsonprint "{message:Hello World!}"