mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-08-16 17:00:32 +03:00
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`
This commit is contained in:
parent
e64355b2ce
commit
36a45f28a3
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user