mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 17:24:20 +02:00
refactor
This commit is contained in:
@@ -4,14 +4,15 @@
|
|||||||
* @copyright Justin Lin, 2017
|
* @copyright Justin Lin, 2017
|
||||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||||
*
|
*
|
||||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-parse_number.html
|
* @see https://openhome.cc/eGossip/OpenSCAD/lib2-parse_number.html
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
function _str_to_int(t, i = 0, mapper = [["0", 0], ["1", 1], ["2", 2], ["3", 3], ["4", 4], ["5", 5], ["6", 6], ["7", 7], ["8", 8], ["9", 9]]) =
|
function _str_to_int(t) =
|
||||||
i == len(mapper) ? -1 : (
|
let(
|
||||||
mapper[i][0] == t ? mapper[i][1] : _str_to_int(t, i + 1)
|
dict = [["0", 0], ["1", 1], ["2", 2], ["3", 3], ["4", 4], ["5", 5], ["6", 6], ["7", 7], ["8", 8], ["9", 9]],
|
||||||
);
|
n = dict[search(t, dict)[0]][1]
|
||||||
|
) n;
|
||||||
|
|
||||||
function _parse_positive_int(t, value = 0, i = 0) =
|
function _parse_positive_int(t, value = 0, i = 0) =
|
||||||
i == len(t) ? value : _parse_positive_int(t, value * pow(10, i) + _str_to_int(t[i]), i + 1);
|
i == len(t) ? value : _parse_positive_int(t, value * pow(10, i) + _str_to_int(t[i]), i + 1);
|
||||||
|
Reference in New Issue
Block a user