-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Co pocita fcelinspace
?
#10
Comments
Jak v kterych pripadech zda se, viz To use or not to use the ++ operator in Elixir. Neocekavam, ze by vystupni list mel byt nejak extremne velky. Vraci list hodnot, ktere maji stejnou vzdalenost mezi sebou, viz napr numpy. |
Vubec ti nevadi, ze ten reduce dela vypocet slozitejsi, kdy mas na vstupu list hodnota a vystupem je list hodnot stejne mohutnosti a prvky jsou na sobe nezavisle? |
Muzes men vysvetlit toto. Pokud pouziji tvou fci |
Tohle uz jsem objevil vcera, ze |
Add reduce - nejde tak ani o rychlost (v pripade malych listu), ale o antipattern. Iterovat nad listem a v kazdem kroku spojovat list je fuj. V pripade reduce listu o |
Cekal bych, ze to api bude prirozene. Chci interval rozdelit na |
No od zacatku bylo S tim prepisem reduce na map def linspace_map(min, max, step)
when is_number(min) and is_number(max) and is_integer(step) and min < max and 1 < step do
delta = :erlang.abs(max - min) / (step - 1)
Enum.map(0..(step - 1), fn i -> min + i * delta end)
end mi benchee dalo pro ##### With input list Enum.to_list(3..1_000_000) #####
Name ips average deviation median 99th %
linspace_map 44.50 M 22.47 ns ±895.01% 16 ns 48 ns
linspace_reduce 43.34 M 23.07 ns ±1415.96% 17 ns 54 ns
Comparison:
linspace_map 44.50 M
linspace_reduce 43.34 M - 1.03x slower +0.60 ns
##### With input list Enum.to_list(3..10_000) #####
Name ips average deviation median 99th %
linspace_map 20.07 M 49.83 ns ±29224.10% 17 ns 49 ns
linspace_reduce 18.03 M 55.46 ns ±34425.83% 17 ns 56 ns
Comparison:
linspace_map 20.07 M
linspace_reduce 18.03 M - 1.11x slower +5.63 ns
##### With small list Enum.to_list(3..100) #####
Name ips average deviation median 99th %
linspace_reduce 22.60 M 44.25 ns ±23637.72% 16 ns 49 ns
linspace_map 21.36 M 46.82 ns ±25684.51% 17 ns 46 ns
Comparison:
linspace_reduce 22.60 M
linspace_map 21.36 M - 1.06x slower +2.56 ns |
Ohanet se ted benchmarkem je zbytecne, ted jde o to, ze to je code antipattern. Neni vubec jasne, co to dela. Druhym faktem je, ze v |
Proc tady to maji takto https://observablehq.com/@d3/axis-ticks?collection=@d3/d3-axis ikdyz popisuji to takto:
Oni pro |
Oni zda se nad tim jeste delaji nejakou chytristiku,
https://observablehq.com/@d3/d3-ticks:
|
jj, to jsem cetl, ale je to ocekavana vec, co uzivatel chce |
Jsem to opravil, ted uz by to melo fungovat ok. |
Proc je pouzit
Enum.reduce/3
a pocetne narocne spojovani listu, kdyz lze pouzitEnum.map/2
.Co je vystupem teto fce, tedy co reprezentuje vraceny seznam?
The text was updated successfully, but these errors were encountered: