Julia Juno Jupyter part1 [無断転載禁止]©2ch.net (745レス)
上下前次1-新
抽出解除 必死チェッカー(本家) (べ) 自ID レス栞 あぼーん
リロード規制です。10分ほどで解除するので、他のブラウザへ避難してください。
21: デフォルトの名無しさん [] 2016/02/15(月) 10:16:09.06 ID:TvNTryet(1/10) AAS
コンパイル中のエラーよりも実行時の型エラーの方が厄介な言語だなこいつは。
慣れれば問題ないが。
22: デフォルトの名無しさん [] 2016/02/15(月) 10:20:41.18 ID:TvNTryet(2/10) AAS
>>1313(1): デフォルトの名無しさん [] 2016/02/13(土) 11:59:14.88 ID:3L3e3K/U(7/7) AAS
もう少しちらうら
julia> bytes2hex([65,97,66,98,0x5c])
ERROR: MethodError: `bytes2hex` has no method matching bytes2hex(::Array{Int32,1})
julia> bytes2hex(Array{UInt8,1}([65,97,66,98,0x5c]))
"416142625c"
julia> bytestring(Array{UInt8,1}([65,97,66,98,0x5c]))
"AaBb\\"
julia> hex2bytes("416142625c")
5-element Array{UInt8,1}: 0x41 0x61 0x42 0x62 0x5c
julia> string2bytes("AaBb\\")
ERROR: UndefVarError: string2bytes not defined
julia> stringbytes("AaBb\\")
ERROR: UndefVarError: stringbytes not defined
julia> read(IOBuffer("AaBb\\"))
ERROR: MethodError: `read` has no method matching read(::Base.AbstractIOBuffer{Array{UInt8,1}})
julia> read(IOBuffer("AaBb\\"), UInt8)
0x41
julia> read(IOBuffer("AaBb\\"), UInt8, length("AaBb\\"))
5-element Array{UInt8,1}: 0x41 0x61 0x42 0x62 0x5c
んー
マニュアルにはreaddim()があるって書いてあるのに・・・
何かimport忘れてるとか?
length省略できんのもなんだかな
勘違いならいいけど
非推奨っぽいが、
これでいいらしい。
"AaBb\\".data
代入も出来るようだ。
s = "AaBb\\"
s.data[2] = UInt8(64)
s
23: デフォルトの名無しさん [] 2016/02/15(月) 10:21:13.05 ID:TvNTryet(3/10) AAS
これは割りと嬉しいかも。
julia> @sprintf "ab [%7s]" "xあx"
"ab [ xあx]"
julia> @sprintf "ab [%-7s]" "xあx"
"ab [xあx ]"
julia> @sprintf "ab [%7s]" "xxx"
"ab [ xxx]"
julia> @sprintf "ab [%-7s]" "xxx"
"ab [xxx ]"
24(1): デフォルトの名無しさん [] 2016/02/15(月) 10:31:07.93 ID:TvNTryet(4/10) AAS
うむむ
julia> @sprintf "ab [%-7s]" bytestring(hex2bytes(""))
"ab [ ]"
julia> @sprintf "ab [%-7s]" bytestring(hex2bytes("4141E381824141"))
"ab [AAあAA ]"
julia> @sprintf "ab [%-7s]" bytestring(hex2bytes("4141E981824141"))
"ab [AA遂AA ]"
julia> @sprintf "ab [%-7s]" bytestring(hex2bytes("4141Ee81824141"))
"ab [AA\ue042AA ]"
julia> @sprintf "ab [%-7s]" bytestring(hex2bytes("4141Ef81824141"))
"ab [AA\uf042AA ]"
julia> @sprintf "ab [%-7s]" bytestring(hex2bytes("4141E881824141"))
"ab [AA聂AA ]"
julia> @sprintf "ab [%-7s]" bytestring(hex2bytes("4141E8e8824141"))
"ab [AA騂AA ]"
julia> @sprintf "ab [%-7s]" bytestring(hex2bytes("4141E9e8824141"))
"ab [AAꨂAA ]"
julia> @sprintf "ab [%-7s]" bytestring(hex2bytes("414155aa554141"))
ERROR: UnicodeError: invalid character index
in next at unicode/utf8.jl:65
in strwidth at strings/basic.jl:205
[inlined code] from printf.jl:159
in anonymous at no file:0
julia> @sprintf "ab [%-7s]" hex2bytes("414155aa554141")
"ab [UInt8[0x41,0x41,0x55,0xaa,0x55,0x41,0x41]]"
25(2): デフォルトの名無しさん [sage] 2016/02/15(月) 11:19:37.91 ID:TvNTryet(5/10) AAS
>>1111(3): デフォルトの名無しさん [sage] 2016/02/13(土) 10:22:27.58 ID:3L3e3K/U(6/7) AAS
ccall(:printf, Void, (Ptr{Cchar}, Ptr{Cchar}), "%s", ccall((:curl_version, :libcurl), Ptr{Cchar}, ()))
err = ccall((:MessageBoxW, :user32), stdcall, UInt, (Ptr{UInt}, Ptr{Cwchar_t}, Ptr{Cwchar_t}, UInt), 0, Array{UInt16,1}([0x304C,0x3063,0xFF01,0]), Array{UInt16,1}([0x306C,0x308B,0x307D,0]), 0)
Array{UInt16,1}のところはArray{Cwchar_t}とかVector{Cwchar_t}とも書ける
err = ccall((:MessageBoxW, :user32), stdcall, UInt, (Ptr{UInt}, Ptr{Cwchar_t}, Ptr{Cwchar_t}, UInt), 0, Vector{Cwchar_t}([0x304C,0x3063,0xFF01,0]), Array{Cwchar_t}([0x306C,0x308B,0x307D,0]), 0)
これでいいね
loadは省けるけど毎回loadと解放してくれてるんだろうか
julia> ccall((:curl_version, :libcurl), Ptr{Cchar}, ())
Ptr{Int8} @0x6b29c060
julia> @sprintf "%s" ccall((:curl_version, :libcurl), Ptr{Cchar}, ())
"Ptr{Int8} @0x6b29c060"
んーこれも期待した動作と違うなぁ。
26: デフォルトの名無しさん [sage] 2016/02/15(月) 11:28:27.71 ID:TvNTryet(6/10) AAS
>>16ifに括弧なしは一見便利だけどend強制されるのはPythonに慣れてるとうざく感じる。
julia> Array{UInt8}([1:n;]) == map(a -> UInt8(a), 1:n)
true
ちょっと気持ち悪いところもある。
27: デフォルトの名無しさん [sage] 2016/02/15(月) 11:32:12.26 ID:TvNTryet(7/10) AAS
julia> Array{UInt8}([1:n;]) == map(a -> UInt8(a), (1:n))
true
julia> Array{UInt8}([1:n]) == map(a -> UInt8(a), (1:n))
警告出るが
true
(二回目からは警告出なくなる?)
julia> Array{UInt8}((1:n)) == map(a -> UInt8(a), (1:n))
エラー
29: デフォルトの名無しさん [sage] 2016/02/15(月) 11:49:21.03 ID:TvNTryet(8/10) AAS
>>28有賀?。
>>24でも書いたけどbytestringってこんなデータ来ると死ぬから使いたくないなぁ。
julia> bytestring(hex2bytes("414155aa554141"))
30(2): デフォルトの名無しさん [sage] 2016/02/15(月) 12:16:36.12 ID:TvNTryet(9/10) AAS
julia> pointer_to_array(ccall((:curl_version, :libcurl), Ptr{Cchar}, ()), n)
でnバイト分のArray{Int8}になるみたいだけどなぜかデフォでUInt8じゃないのが気に入らないなぁ。
julia> Array{UInt8}(pointer_to_array(ccall((:curl_version, :libcurl), Ptr{Cchar}, ()), n))
とかいちいち書くの面倒だなぁ。
32(1): デフォルトの名無しさん [sage] 2016/02/15(月) 12:21:09.84 ID:TvNTryet(10/10) AAS
>>31julia> pointer_to_array(ccall((:curl_version, :libcurl), Ptr{UInt8}, ()), n)
できました!!
ありがとうございます!!!
上下前次1-新書関写板覧索設栞歴
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.024s