Size: a a a

2020 June 06

DF

Dollar Føølish in rust_offtopic
Пдф это рисунок а не документ
источник

AZ

Alex Zhukovsky in rust_offtopic
data Format =
     Number Format
   | Str Format
   | Lit String Format
   | End

PrintfType : Format -> Type
PrintfType (Number fmt) = (i : Int) -> PrintfType fmt
PrintfType (Str fmt) = (str : String) -> PrintfType fmt
PrintfType (Lit str fmt) = PrintfType fmt
PrintfType End = String

toFormat : (xs : List Char) -> Format
toFormat [] = End
toFormat ('%' :: 'd' :: tail) = Number (toFormat tail)
toFormat ('%' :: 's' :: tail) = Str (toFormat tail)
toFormat (x :: tail) = Lit (cast x) (toFormat tail)

reduceFormat : Format -> Format
reduceFormat (Number x) = Number (reduceFormat x)
reduceFormat (Str x) = Str (reduceFormat x)
reduceFormat (Lit x (Lit y t)) = reduceFormat (Lit (x ++ y) t)
reduceFormat (Lit x y) = Lit x (reduceFormat y)
reduceFormat End = End
источник

AZ

Alex Zhukovsky in rust_offtopic
@hirrolot зацени красоту
источник

T1

Tony 123 in rust_offtopic
источник

AZ

Alex Zhukovsky in rust_offtopic
toFormat (cast "Hell%o!%")

vs

reduceFormat (toFormat (cast "Hell%o!%"))
источник

AZ

Alex Zhukovsky in rust_offtopic
даже лучше чем в книжке)
источник

G

Gymmasssorla in rust_offtopic
Alex Zhukovsky
data Format =
     Number Format
   | Str Format
   | Lit String Format
   | End

PrintfType : Format -> Type
PrintfType (Number fmt) = (i : Int) -> PrintfType fmt
PrintfType (Str fmt) = (str : String) -> PrintfType fmt
PrintfType (Lit str fmt) = PrintfType fmt
PrintfType End = String

toFormat : (xs : List Char) -> Format
toFormat [] = End
toFormat ('%' :: 'd' :: tail) = Number (toFormat tail)
toFormat ('%' :: 's' :: tail) = Str (toFormat tail)
toFormat (x :: tail) = Lit (cast x) (toFormat tail)

reduceFormat : Format -> Format
reduceFormat (Number x) = Number (reduceFormat x)
reduceFormat (Str x) = Str (reduceFormat x)
reduceFormat (Lit x (Lit y t)) = reduceFormat (Lit (x ++ y) t)
reduceFormat (Lit x y) = Lit x (reduceFormat y)
reduceFormat End = End
Это же в книжке Idris, нет?
источник

G

Gymmasssorla in rust_offtopic
Alex Zhukovsky
даже лучше чем в книжке)
Аа
источник

AZ

Alex Zhukovsky in rust_offtopic
прост сравни вариант из книжки как отработает
источник

G

Gymmasssorla in rust_offtopic
Ну можно, наверное, вариант из книжки упростить с использованием auto prf
источник

AZ

Alex Zhukovsky in rust_offtopic
Gymmasssorla
Ну можно, наверное, вариант из книжки упростить с использованием auto prf
при чем тут это?
источник

G

Gymmasssorla in rust_offtopic
Чтобы оно само неявно вычисляло формат из строки
источник

SP

Stanislav Popov in rust_offtopic
Doge Shibu
Может без анврапов повсюду и не будет паник?
неа
источник

p

polunin.ai in rust_offtopic
что я делаю не так
источник

DS

Doge Shibu in rust_offtopic
Ещё можно stop_on_panic
источник

p

polunin.ai in rust_offtopic
почему setChats() не работает
источник

p

polunin.ai in rust_offtopic
@enomad памаги
источник

p

polunin.ai in rust_offtopic
polunin.ai
что я делаю не так
вот вывод
источник

p

polunin.ai in rust_offtopic
но при этом setChats не срабатывает, в стейте остается все еще пустой массив
источник

p

polunin.ai in rust_offtopic
polunin.ai
что я делаю не так
источник