locutus 2.0.35 → 2.0.37
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.
- package/awk/builtin/cos.js +11 -0
- package/awk/builtin/exp.js +11 -0
- package/awk/builtin/index.js +5 -0
- package/awk/builtin/log.js +11 -0
- package/awk/builtin/sin.js +11 -0
- package/awk/builtin/sqrt.js +11 -0
- package/clojure/string/blank.js +17 -0
- package/clojure/string/index.js +5 -0
- package/clojure/string/lower_case.js +12 -0
- package/clojure/string/reverse.js +11 -0
- package/clojure/string/trim.js +11 -0
- package/clojure/string/upper_case.js +12 -0
- package/elixir/String/downcase.js +11 -0
- package/elixir/String/index.js +4 -0
- package/elixir/String/length.js +11 -0
- package/elixir/String/reverse.js +11 -0
- package/elixir/String/upcase.js +11 -0
- package/julia/Base/index.js +2 -0
- package/julia/Base/lowercase.js +11 -0
- package/julia/Base/uppercase.js +11 -0
- package/lua/math/cos.js +11 -0
- package/lua/math/index.js +5 -0
- package/lua/math/max.js +11 -0
- package/lua/math/min.js +11 -0
- package/lua/math/sin.js +11 -0
- package/lua/math/sqrt.js +11 -0
- package/lua/string/index.js +3 -0
- package/lua/string/len.js +11 -0
- package/lua/string/rep.js +14 -0
- package/lua/string/reverse.js +11 -0
- package/package.json +1 -1
- package/perl/core/index.js +4 -0
- package/perl/core/lc.js +11 -0
- package/perl/core/reverse.js +12 -0
- package/perl/core/substr.js +44 -0
- package/perl/core/uc.js +11 -0
- package/r/base/index.js +7 -0
- package/r/base/max.js +11 -0
- package/r/base/min.js +11 -0
- package/r/base/nchar.js +11 -0
- package/r/base/round.js +15 -0
- package/r/base/sqrt.js +11 -0
- package/r/base/tolower.js +11 -0
- package/r/base/toupper.js +11 -0
- package/{_data/rosetta.yml → rosetta.yml} +48 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function cos(x) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/cos/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: cos(0)
|
|
6
|
+
// returns 1: 1
|
|
7
|
+
// example 2: cos(1)
|
|
8
|
+
// returns 2: 0.5403023058681398
|
|
9
|
+
|
|
10
|
+
return Math.cos(x)
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function exp(x) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/exp/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: exp(0)
|
|
6
|
+
// returns 1: 1
|
|
7
|
+
// example 2: exp(1)
|
|
8
|
+
// returns 2: 2.718281828459045
|
|
9
|
+
|
|
10
|
+
return Math.exp(x)
|
|
11
|
+
}
|
package/awk/builtin/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
module.exports.cos = require('./cos')
|
|
2
|
+
module.exports.exp = require('./exp')
|
|
1
3
|
module.exports.int = require('./int')
|
|
2
4
|
module.exports.length = require('./length')
|
|
5
|
+
module.exports.log = require('./log')
|
|
6
|
+
module.exports.sin = require('./sin')
|
|
7
|
+
module.exports.sqrt = require('./sqrt')
|
|
3
8
|
module.exports.substr = require('./substr')
|
|
4
9
|
module.exports.tolower = require('./tolower')
|
|
5
10
|
module.exports.toupper = require('./toupper')
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function log(x) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/log/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: log(1)
|
|
6
|
+
// returns 1: 0
|
|
7
|
+
// example 2: log(2.718281828459045)
|
|
8
|
+
// returns 2: 1
|
|
9
|
+
|
|
10
|
+
return Math.log(x)
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function sin(x) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/sin/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: sin(0)
|
|
6
|
+
// returns 1: 0
|
|
7
|
+
// example 2: sin(1)
|
|
8
|
+
// returns 2: 0.8414709848078965
|
|
9
|
+
|
|
10
|
+
return Math.sin(x)
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function sqrt(x) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/sqrt/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: sqrt(16)
|
|
6
|
+
// returns 1: 4
|
|
7
|
+
// example 2: sqrt(2)
|
|
8
|
+
// returns 2: 1.4142135623730951
|
|
9
|
+
|
|
10
|
+
return Math.sqrt(x)
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = function blank(s) {
|
|
2
|
+
// discuss at: https://locutus.io/clojure/blank/
|
|
3
|
+
// parity verified: Clojure 1.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Clojure uses blank?, JS uses blank
|
|
6
|
+
// example 1: blank('')
|
|
7
|
+
// returns 1: true
|
|
8
|
+
// example 2: blank(' ')
|
|
9
|
+
// returns 2: true
|
|
10
|
+
// example 3: blank('hello')
|
|
11
|
+
// returns 3: false
|
|
12
|
+
|
|
13
|
+
if (s === null || s === undefined) {
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
return String(s).trim().length === 0
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = function lower_case(s) {
|
|
2
|
+
// discuss at: https://locutus.io/clojure/lower_case/
|
|
3
|
+
// parity verified: Clojure 1.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Clojure uses lower-case, JS uses lower_case
|
|
6
|
+
// example 1: lower_case('HELLO')
|
|
7
|
+
// returns 1: 'hello'
|
|
8
|
+
// example 2: lower_case('Hello World')
|
|
9
|
+
// returns 2: 'hello world'
|
|
10
|
+
|
|
11
|
+
return String(s).toLowerCase()
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function reverse(s) {
|
|
2
|
+
// discuss at: https://locutus.io/clojure/reverse/
|
|
3
|
+
// parity verified: Clojure 1.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: reverse('hello')
|
|
6
|
+
// returns 1: 'olleh'
|
|
7
|
+
// example 2: reverse('abc')
|
|
8
|
+
// returns 2: 'cba'
|
|
9
|
+
|
|
10
|
+
return String(s).split('').reverse().join('')
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function trim(s) {
|
|
2
|
+
// discuss at: https://locutus.io/clojure/trim/
|
|
3
|
+
// parity verified: Clojure 1.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: trim(' hello ')
|
|
6
|
+
// returns 1: 'hello'
|
|
7
|
+
// example 2: trim('abc')
|
|
8
|
+
// returns 2: 'abc'
|
|
9
|
+
|
|
10
|
+
return String(s).trim()
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = function upper_case(s) {
|
|
2
|
+
// discuss at: https://locutus.io/clojure/upper_case/
|
|
3
|
+
// parity verified: Clojure 1.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Clojure uses upper-case, JS uses upper_case
|
|
6
|
+
// example 1: upper_case('hello')
|
|
7
|
+
// returns 1: 'HELLO'
|
|
8
|
+
// example 2: upper_case('Hello World')
|
|
9
|
+
// returns 2: 'HELLO WORLD'
|
|
10
|
+
|
|
11
|
+
return String(s).toUpperCase()
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function downcase(string) {
|
|
2
|
+
// discuss at: https://locutus.io/elixir/downcase/
|
|
3
|
+
// parity verified: Elixir 1.18
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: downcase('HELLO')
|
|
6
|
+
// returns 1: 'hello'
|
|
7
|
+
// example 2: downcase('Hello World')
|
|
8
|
+
// returns 2: 'hello world'
|
|
9
|
+
|
|
10
|
+
return String(string).toLowerCase()
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function length(string) {
|
|
2
|
+
// discuss at: https://locutus.io/elixir/length/
|
|
3
|
+
// parity verified: Elixir 1.18
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: length('hello')
|
|
6
|
+
// returns 1: 5
|
|
7
|
+
// example 2: length('')
|
|
8
|
+
// returns 2: 0
|
|
9
|
+
|
|
10
|
+
return String(string).length
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function reverse(string) {
|
|
2
|
+
// discuss at: https://locutus.io/elixir/reverse/
|
|
3
|
+
// parity verified: Elixir 1.18
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: reverse('hello')
|
|
6
|
+
// returns 1: 'olleh'
|
|
7
|
+
// example 2: reverse('abc')
|
|
8
|
+
// returns 2: 'cba'
|
|
9
|
+
|
|
10
|
+
return String(string).split('').reverse().join('')
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function upcase(string) {
|
|
2
|
+
// discuss at: https://locutus.io/elixir/upcase/
|
|
3
|
+
// parity verified: Elixir 1.18
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: upcase('hello')
|
|
6
|
+
// returns 1: 'HELLO'
|
|
7
|
+
// example 2: upcase('Hello World')
|
|
8
|
+
// returns 2: 'HELLO WORLD'
|
|
9
|
+
|
|
10
|
+
return String(string).toUpperCase()
|
|
11
|
+
}
|
package/julia/Base/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function lowercase(s) {
|
|
2
|
+
// discuss at: https://locutus.io/julia/lowercase/
|
|
3
|
+
// parity verified: Julia 1.11
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: lowercase('HELLO')
|
|
6
|
+
// returns 1: 'hello'
|
|
7
|
+
// example 2: lowercase('Hello World')
|
|
8
|
+
// returns 2: 'hello world'
|
|
9
|
+
|
|
10
|
+
return String(s).toLowerCase()
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function uppercase(s) {
|
|
2
|
+
// discuss at: https://locutus.io/julia/uppercase/
|
|
3
|
+
// parity verified: Julia 1.11
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: uppercase('hello')
|
|
6
|
+
// returns 1: 'HELLO'
|
|
7
|
+
// example 2: uppercase('Hello World')
|
|
8
|
+
// returns 2: 'HELLO WORLD'
|
|
9
|
+
|
|
10
|
+
return String(s).toUpperCase()
|
|
11
|
+
}
|
package/lua/math/cos.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function cos(x) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/cos/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: cos(0)
|
|
6
|
+
// returns 1: 1
|
|
7
|
+
// example 2: cos(1)
|
|
8
|
+
// returns 2: 0.5403023058681398
|
|
9
|
+
|
|
10
|
+
return Math.cos(x)
|
|
11
|
+
}
|
package/lua/math/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
module.exports.abs = require('./abs')
|
|
2
2
|
module.exports.ceil = require('./ceil')
|
|
3
|
+
module.exports.cos = require('./cos')
|
|
3
4
|
module.exports.floor = require('./floor')
|
|
5
|
+
module.exports.max = require('./max')
|
|
6
|
+
module.exports.min = require('./min')
|
|
7
|
+
module.exports.sin = require('./sin')
|
|
8
|
+
module.exports.sqrt = require('./sqrt')
|
package/lua/math/max.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function max(...args) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/max/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: max(1, 5, 3)
|
|
6
|
+
// returns 1: 5
|
|
7
|
+
// example 2: max(-1, -5)
|
|
8
|
+
// returns 2: -1
|
|
9
|
+
|
|
10
|
+
return Math.max(...args)
|
|
11
|
+
}
|
package/lua/math/min.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function min(...args) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/min/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: min(1, 5, 3)
|
|
6
|
+
// returns 1: 1
|
|
7
|
+
// example 2: min(-1, -5)
|
|
8
|
+
// returns 2: -5
|
|
9
|
+
|
|
10
|
+
return Math.min(...args)
|
|
11
|
+
}
|
package/lua/math/sin.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function sin(x) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/sin/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: sin(0)
|
|
6
|
+
// returns 1: 0
|
|
7
|
+
// example 2: sin(1)
|
|
8
|
+
// returns 2: 0.8414709848078965
|
|
9
|
+
|
|
10
|
+
return Math.sin(x)
|
|
11
|
+
}
|
package/lua/math/sqrt.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function sqrt(x) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/sqrt/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: sqrt(16)
|
|
6
|
+
// returns 1: 4
|
|
7
|
+
// example 2: sqrt(2)
|
|
8
|
+
// returns 2: 1.4142135623730951
|
|
9
|
+
|
|
10
|
+
return Math.sqrt(x)
|
|
11
|
+
}
|
package/lua/string/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function len(s) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/len/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: len('hello')
|
|
6
|
+
// returns 1: 5
|
|
7
|
+
// example 2: len('')
|
|
8
|
+
// returns 2: 0
|
|
9
|
+
|
|
10
|
+
return String(s).length
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = function rep(s, n) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/rep/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: rep('ab', 3)
|
|
6
|
+
// returns 1: 'ababab'
|
|
7
|
+
// example 2: rep('x', 5)
|
|
8
|
+
// returns 2: 'xxxxx'
|
|
9
|
+
|
|
10
|
+
if (n <= 0) {
|
|
11
|
+
return ''
|
|
12
|
+
}
|
|
13
|
+
return String(s).repeat(n)
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function reverse(s) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/reverse/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: reverse('hello')
|
|
6
|
+
// returns 1: 'olleh'
|
|
7
|
+
// example 2: reverse('abc')
|
|
8
|
+
// returns 2: 'cba'
|
|
9
|
+
|
|
10
|
+
return String(s).split('').reverse().join('')
|
|
11
|
+
}
|
package/package.json
CHANGED
package/perl/core/index.js
CHANGED
package/perl/core/lc.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function lc(str) {
|
|
2
|
+
// discuss at: https://locutus.io/perl/lc/
|
|
3
|
+
// parity verified: Perl 5.40
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: lc('HELLO')
|
|
6
|
+
// returns 1: 'hello'
|
|
7
|
+
// example 2: lc('Hello World')
|
|
8
|
+
// returns 2: 'hello world'
|
|
9
|
+
|
|
10
|
+
return String(str).toLowerCase()
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = function reverse(str) {
|
|
2
|
+
// discuss at: https://locutus.io/perl/reverse/
|
|
3
|
+
// parity verified: Perl 5.40
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: In scalar context, reverses string characters
|
|
6
|
+
// example 1: reverse('hello')
|
|
7
|
+
// returns 1: 'olleh'
|
|
8
|
+
// example 2: reverse('abc')
|
|
9
|
+
// returns 2: 'cba'
|
|
10
|
+
|
|
11
|
+
return String(str).split('').reverse().join('')
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module.exports = function substr(str, offset, length) {
|
|
2
|
+
// discuss at: https://locutus.io/perl/substr/
|
|
3
|
+
// parity verified: Perl 5.40
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Perl's offset is 0-based, negative counts from end
|
|
6
|
+
// example 1: substr('hello', 0, 3)
|
|
7
|
+
// returns 1: 'hel'
|
|
8
|
+
// example 2: substr('hello', 1)
|
|
9
|
+
// returns 2: 'ello'
|
|
10
|
+
// example 3: substr('hello', -2)
|
|
11
|
+
// returns 3: 'lo'
|
|
12
|
+
|
|
13
|
+
str = String(str)
|
|
14
|
+
const len = str.length
|
|
15
|
+
|
|
16
|
+
// Handle negative offset (count from end)
|
|
17
|
+
let start = offset < 0 ? len + offset : offset
|
|
18
|
+
|
|
19
|
+
// Clamp start to valid range
|
|
20
|
+
if (start < 0) {
|
|
21
|
+
start = 0
|
|
22
|
+
}
|
|
23
|
+
if (start > len) {
|
|
24
|
+
return ''
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// If length is undefined, return rest of string
|
|
28
|
+
if (length === undefined) {
|
|
29
|
+
return str.substring(start)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Handle negative length (leave that many chars at end)
|
|
33
|
+
let end
|
|
34
|
+
if (length < 0) {
|
|
35
|
+
end = len + length
|
|
36
|
+
if (end < start) {
|
|
37
|
+
return ''
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
end = start + length
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return str.substring(start, end)
|
|
44
|
+
}
|
package/perl/core/uc.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function uc(str) {
|
|
2
|
+
// discuss at: https://locutus.io/perl/uc/
|
|
3
|
+
// parity verified: Perl 5.40
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: uc('hello')
|
|
6
|
+
// returns 1: 'HELLO'
|
|
7
|
+
// example 2: uc('Hello World')
|
|
8
|
+
// returns 2: 'HELLO WORLD'
|
|
9
|
+
|
|
10
|
+
return String(str).toUpperCase()
|
|
11
|
+
}
|
package/r/base/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
module.exports.abs = require('./abs')
|
|
2
2
|
module.exports.ceiling = require('./ceiling')
|
|
3
3
|
module.exports.floor = require('./floor')
|
|
4
|
+
module.exports.max = require('./max')
|
|
5
|
+
module.exports.min = require('./min')
|
|
6
|
+
module.exports.nchar = require('./nchar')
|
|
7
|
+
module.exports.round = require('./round')
|
|
8
|
+
module.exports.sqrt = require('./sqrt')
|
|
9
|
+
module.exports.tolower = require('./tolower')
|
|
10
|
+
module.exports.toupper = require('./toupper')
|
package/r/base/max.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function max(...args) {
|
|
2
|
+
// discuss at: https://locutus.io/r/max/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: max(1, 5, 3)
|
|
6
|
+
// returns 1: 5
|
|
7
|
+
// example 2: max(-1, -5)
|
|
8
|
+
// returns 2: -1
|
|
9
|
+
|
|
10
|
+
return Math.max(...args)
|
|
11
|
+
}
|
package/r/base/min.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function min(...args) {
|
|
2
|
+
// discuss at: https://locutus.io/r/min/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: min(1, 5, 3)
|
|
6
|
+
// returns 1: 1
|
|
7
|
+
// example 2: min(-1, -5)
|
|
8
|
+
// returns 2: -5
|
|
9
|
+
|
|
10
|
+
return Math.min(...args)
|
|
11
|
+
}
|
package/r/base/nchar.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function nchar(x) {
|
|
2
|
+
// discuss at: https://locutus.io/r/nchar/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: nchar('hello')
|
|
6
|
+
// returns 1: 5
|
|
7
|
+
// example 2: nchar('')
|
|
8
|
+
// returns 2: 0
|
|
9
|
+
|
|
10
|
+
return String(x).length
|
|
11
|
+
}
|
package/r/base/round.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = function round(x, digits) {
|
|
2
|
+
// discuss at: https://locutus.io/r/round/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: round(3.14159)
|
|
6
|
+
// returns 1: 3
|
|
7
|
+
// example 2: round(3.14159, 2)
|
|
8
|
+
// returns 2: 3.14
|
|
9
|
+
|
|
10
|
+
if (digits === undefined || digits === 0) {
|
|
11
|
+
return Math.round(x)
|
|
12
|
+
}
|
|
13
|
+
const factor = Math.pow(10, digits)
|
|
14
|
+
return Math.round(x * factor) / factor
|
|
15
|
+
}
|
package/r/base/sqrt.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function sqrt(x) {
|
|
2
|
+
// discuss at: https://locutus.io/r/sqrt/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: sqrt(16)
|
|
6
|
+
// returns 1: 4
|
|
7
|
+
// example 2: sqrt(2)
|
|
8
|
+
// returns 2: 1.4142135623730951
|
|
9
|
+
|
|
10
|
+
return Math.sqrt(x)
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function tolower(x) {
|
|
2
|
+
// discuss at: https://locutus.io/r/tolower/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: tolower('HELLO')
|
|
6
|
+
// returns 1: 'hello'
|
|
7
|
+
// example 2: tolower('Hello World')
|
|
8
|
+
// returns 2: 'hello world'
|
|
9
|
+
|
|
10
|
+
return String(x).toLowerCase()
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function toupper(x) {
|
|
2
|
+
// discuss at: https://locutus.io/r/toupper/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: toupper('hello')
|
|
6
|
+
// returns 1: 'HELLO'
|
|
7
|
+
// example 2: toupper('Hello World')
|
|
8
|
+
// returns 2: 'HELLO WORLD'
|
|
9
|
+
|
|
10
|
+
return String(x).toUpperCase()
|
|
11
|
+
}
|
|
@@ -16,22 +16,40 @@ string_length:
|
|
|
16
16
|
- ruby/String/length
|
|
17
17
|
- perl/core/length
|
|
18
18
|
- awk/builtin/length
|
|
19
|
+
- lua/string/len
|
|
20
|
+
- elixir/String/length
|
|
21
|
+
- r/base/nchar
|
|
19
22
|
|
|
20
23
|
string_lowercase:
|
|
21
24
|
- php/strings/strtolower
|
|
22
25
|
- ruby/String/downcase
|
|
23
26
|
- golang/strings/ToLower
|
|
27
|
+
- lua/string/lower
|
|
28
|
+
- perl/core/lc
|
|
29
|
+
- awk/builtin/tolower
|
|
30
|
+
- r/base/tolower
|
|
31
|
+
- julia/Base/lowercase
|
|
32
|
+
- elixir/String/downcase
|
|
33
|
+
- clojure/string/lower_case
|
|
24
34
|
|
|
25
35
|
string_uppercase:
|
|
26
36
|
- php/strings/strtoupper
|
|
27
37
|
- ruby/String/upcase
|
|
28
38
|
- golang/strings/ToUpper
|
|
39
|
+
- lua/string/upper
|
|
40
|
+
- perl/core/uc
|
|
41
|
+
- awk/builtin/toupper
|
|
42
|
+
- r/base/toupper
|
|
43
|
+
- julia/Base/uppercase
|
|
44
|
+
- elixir/String/upcase
|
|
45
|
+
- clojure/string/upper_case
|
|
29
46
|
|
|
30
47
|
string_trim:
|
|
31
48
|
- php/strings/trim
|
|
32
49
|
- ruby/String/strip
|
|
33
50
|
- golang/strings/TrimSpace
|
|
34
51
|
- golang/strings/Trim
|
|
52
|
+
- clojure/string/trim
|
|
35
53
|
|
|
36
54
|
string_rtrim:
|
|
37
55
|
- php/strings/rtrim
|
|
@@ -54,6 +72,10 @@ string_ends_with:
|
|
|
54
72
|
string_reverse:
|
|
55
73
|
- php/strings/strrev
|
|
56
74
|
- ruby/String/reverse
|
|
75
|
+
- lua/string/reverse
|
|
76
|
+
- perl/core/reverse
|
|
77
|
+
- elixir/String/reverse
|
|
78
|
+
- clojure/string/reverse
|
|
57
79
|
|
|
58
80
|
string_split:
|
|
59
81
|
- php/strings/explode
|
|
@@ -79,6 +101,7 @@ string_last_index:
|
|
|
79
101
|
string_repeat:
|
|
80
102
|
- php/strings/str_repeat
|
|
81
103
|
- golang/strings/Repeat
|
|
104
|
+
- lua/string/rep
|
|
82
105
|
|
|
83
106
|
string_capitalize:
|
|
84
107
|
- php/strings/ucfirst
|
|
@@ -104,6 +127,8 @@ string_count:
|
|
|
104
127
|
string_substring:
|
|
105
128
|
- php/strings/substr
|
|
106
129
|
- awk/builtin/substr
|
|
130
|
+
- lua/string/sub
|
|
131
|
+
- perl/core/substr
|
|
107
132
|
|
|
108
133
|
# =============================================================================
|
|
109
134
|
# MATH OPERATIONS
|
|
@@ -113,16 +138,21 @@ math_sqrt:
|
|
|
113
138
|
- php/math/sqrt
|
|
114
139
|
- python/math/sqrt
|
|
115
140
|
- ruby/Math/sqrt
|
|
141
|
+
- lua/math/sqrt
|
|
142
|
+
- awk/builtin/sqrt
|
|
143
|
+
- r/base/sqrt
|
|
116
144
|
|
|
117
145
|
math_exp:
|
|
118
146
|
- php/math/exp
|
|
119
147
|
- python/math/exp
|
|
120
148
|
- ruby/Math/exp
|
|
149
|
+
- awk/builtin/exp
|
|
121
150
|
|
|
122
151
|
math_log:
|
|
123
152
|
- php/math/log
|
|
124
153
|
- python/math/log
|
|
125
154
|
- ruby/Math/log
|
|
155
|
+
- awk/builtin/log
|
|
126
156
|
|
|
127
157
|
math_log10:
|
|
128
158
|
- php/math/log10
|
|
@@ -136,10 +166,14 @@ math_log2:
|
|
|
136
166
|
math_sin:
|
|
137
167
|
- php/math/sin
|
|
138
168
|
- ruby/Math/sin
|
|
169
|
+
- lua/math/sin
|
|
170
|
+
- awk/builtin/sin
|
|
139
171
|
|
|
140
172
|
math_cos:
|
|
141
173
|
- php/math/cos
|
|
142
174
|
- ruby/Math/cos
|
|
175
|
+
- lua/math/cos
|
|
176
|
+
- awk/builtin/cos
|
|
143
177
|
|
|
144
178
|
math_tan:
|
|
145
179
|
- php/math/tan
|
|
@@ -198,6 +232,20 @@ math_abs:
|
|
|
198
232
|
- elixir/Kernel/abs
|
|
199
233
|
- clojure/Math/abs
|
|
200
234
|
|
|
235
|
+
math_max:
|
|
236
|
+
- php/math/max
|
|
237
|
+
- lua/math/max
|
|
238
|
+
- r/base/max
|
|
239
|
+
|
|
240
|
+
math_min:
|
|
241
|
+
- php/math/min
|
|
242
|
+
- lua/math/min
|
|
243
|
+
- r/base/min
|
|
244
|
+
|
|
245
|
+
math_round:
|
|
246
|
+
- php/math/round
|
|
247
|
+
- r/base/round
|
|
248
|
+
|
|
201
249
|
math_fabs:
|
|
202
250
|
- python/math/fabs
|
|
203
251
|
|