From 36a45f28a39ee1526a748b53f438a41ae939fc7c Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Wed, 20 Sep 2023 19:13:52 +0200 Subject: [PATCH] Move `random/into decimal` to `random/into float` (#606) * Move `random-list decimal` to `random-list float` Updates internally to `random float` published with `0.85` * Update kubernetes wrapper to `into float` * Update temp script to `into float` * Update `nupass` to `random float` --- modules/random-list/random-list.nu | 6 +++--- sourced/misc/password_generator/nupass.nu | 2 +- sourced/temp.nu | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/random-list/random-list.nu b/modules/random-list/random-list.nu index 3b6a58a..20cf509 100644 --- a/modules/random-list/random-list.nu +++ b/modules/random-list/random-list.nu @@ -47,8 +47,8 @@ export def "random-list chars" [ } } -# Generate a random decimal list. -export def "random-list decimal" [ +# Generate a random float list. +export def "random-list float" [ list_length: int, # A length of the list --range (-r): range # A range of the value ] { @@ -57,7 +57,7 @@ export def "random-list decimal" [ } 1..$list_length | each {|it| - random decimal $range + random float $range } } diff --git a/sourced/misc/password_generator/nupass.nu b/sourced/misc/password_generator/nupass.nu index 7492b85..84b87f4 100755 --- a/sourced/misc/password_generator/nupass.nu +++ b/sourced/misc/password_generator/nupass.nu @@ -102,7 +102,7 @@ def random-format-word [] { } else if $rint == 2 { ($it | str upcase) } else if $rint == 3 { - ($it | split chars | each {|c| if (random decimal) < 0.2 { $c | str upcase } else { $c }} | str join "") + ($it | split chars | each {|c| if (random float) < 0.2 { $c | str upcase } else { $c }} | str join "") } else { ($it | str downcase) } diff --git a/sourced/temp.nu b/sourced/temp.nu index 7d7e27b..4edd2bb 100644 --- a/sourced/temp.nu +++ b/sourced/temp.nu @@ -5,7 +5,7 @@ export def f-to-c [ --round(-r): int = 2 # Digits of precision to round to ] { # (100°F − 32) × 5/9 = 37.778°C - let $n = if ($fahren | describe) == "float" {$fahren} else {$fahren | into decimal } + let $n = if ($fahren | describe) == "float" {$fahren} else {$fahren | into float } let celcius = ((( $n - 32.) * 5 / 9. ) | math round -p $round ) $"($fahren) °F is ($celcius) °C" } @@ -17,7 +17,7 @@ export def f-to-k [ ] { # (100°F − 32) × 5/9 + 273.15 = 310.928K - let $n = if ($fahren | describe) == "float" {$fahren} else {$fahren | into decimal } + let $n = if ($fahren | describe) == "float" {$fahren} else {$fahren | into float } let kelvin = ((($n - 32) * 5 / 9 + 273.15)| math round -p $round ) $"($fahren) °F is ($kelvin) °K" } @@ -29,7 +29,7 @@ export def c-to-f [ ] { # (100°C × 9/5) + 32 = 212°F - let $n = if ($celcius | describe) == "float" {$celcius} else {$celcius | into decimal } + let $n = if ($celcius | describe) == "float" {$celcius} else {$celcius | into float } let fahren = ((($n * 9 / 5) + 32) | math round -p $round ) $"($celcius) °C is ($fahren) °F" } @@ -42,7 +42,7 @@ export def c-to-k [ # 100°C + 273.15 = 373.15K - let $n = if ($celcius | describe) == "float" {$celcius} else {$celcius | into decimal } + let $n = if ($celcius | describe) == "float" {$celcius} else {$celcius | into float } let kelvin = (($n + 273.15) | math round -p $round ) $"($celcius) °C is ($kelvin) °K" } @@ -54,7 +54,7 @@ export def k-to-f [ ] { # (100K − 273.15) × 9/5 + 32 = -279.7°F - let $n = if ($kelvin | describe) == "float" {$kelvin} else {$kelvin | into decimal } + let $n = if ($kelvin | describe) == "float" {$kelvin} else {$kelvin | into float } let fahren = ((($n - 273.15) * 9 / 5 + 32) | math round -p $round ) $"($kelvin) °K is ($fahren) °F" } @@ -66,7 +66,7 @@ export def k-to-c [ ] { # 100K − 273.15 = -173.1°C - let $n = if ($kelvin | describe) == "float" {$kelvin} else {$kelvin | into decimal } + let $n = if ($kelvin | describe) == "float" {$kelvin} else {$kelvin | into float } let celcius = (($n - 273.15) | math round -p $round ) $"($kelvin) °K is ($celcius) °C" }