Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
[slack] <pfitzseb> you can't with normal arrays -- their type doesn't include any information about the vector's length
[slack] <pfitzseb> you can look into StaticArrays.jl though, which do include that info in their type
BridgingBot
@GitterIRCbot
[irc] <uskerine> but if I do this: a = Vector{Int32}(undef, 4) I allocate space for a 4 item vector, right?
[slack] <pfitzseb> yes
BridgingBot
@GitterIRCbot
[irc] <uskerine> I see, but you can not specify that as return value of a function
[irc] <uskerine> btw, what is the value of specifying a return value of a function?
[irc] <uskerine> by value I mean benefit
BridgingBot
@GitterIRCbot
[slack] <pfitzseb> it can improve performance if Julia can't infer the return type on it's own
[slack] <pfitzseb> and it helps with correctness, because you get a runtime error if return value can't be converted to the indicated return type
[slack] <pfitzseb> julia> typeof((Int32(1), Int32(2), Int32(3), Int32(4)))
NTuple{4,Int32}
BridgingBot
@GitterIRCbot
[irc] <uskerine> Thanks, I am trying to get that be the value of a returned function now
[irc] <uskerine> please kindly see edited question
BridgingBot
@GitterIRCbot
[irc] <uskerine> nah I found the issue, I was using Tuple instead of NTuple in the return
BridgingBot
@GitterIRCbot
[irc] <uskerine> hi, how can I do CHR(65) in Julia?
[irc] <uskerine> and given a = "B" how can I add 1 so I get a = "C"?
BridgingBot
@GitterIRCbot
[slack] <saschamann> if a is a single char, you can do a = 'B' and a + 1 to get 'C'
[slack] <saschamann> if it's a string, this works: join(char + 1 for char in a)
[slack] <saschamann> I'm not sure what CHR(65) does
[irc] <uskerine> Thanks, if I do myVar = "A", is that a single character? I thought Julia did not have char, just strings
[slack] <saschamann> use single quotes for chars
[irc] <uskerine> so myVar = 'A'
[irc] <uskerine> is actually what I am looking for if I want to deal with single char, right?
[slack] <saschamann> yep
[irc] <uskerine> thanks
[slack] <saschamann> The manual has some more details on chars: https://docs.julialang.org/en/v1/manual/strings/#man-characters-1
BridgingBot
@GitterIRCbot
[irc] <uskerine> hi, how can I get the last character of a string
[irc] <uskerine> ?
[irc] <uskerine> thanks
BridgingBot
@GitterIRCbot
[slack] <pfitzseb> str = "αβasdγ" str[lastindex(str)]
BridgingBot
@GitterIRCbot
[slack] <loki._.> or last(„αβasdγ“)
BridgingBot
@GitterIRCbot
[irc] <uskerine> thanks pfitzseb/loki (other's day question about last character of string)
BridgingBot
@GitterIRCbot
[irc] <uskerine> how can I concatenate a string and a letter¿?
[irc] <uskerine> and how can I assign a single letter to a string?
[irc] <uskerine> I saw it is string(letter)
BridgingBot
@GitterIRCbot

[slack] <jeffrey_sarnoff> ```
julia> str = "a"; ltr = 'b';

julia> string(str, ltr), string(ltr, str)
("ab", "ba")
```

BridgingBot
@GitterIRCbot
[slack] <rfourquet> also str * ltr and ltr ^ 1 (equivalent to string(ltr))
BridgingBot
@GitterIRCbot
[irc] <uskerine> thanks rfourquet
BridgingBot
@GitterIRCbot
[irc] <uskerine> for r in eachrow(df) ... end
[irc] <uskerine> how do I assign a value of column name "D" in df using above for?
BridgingBot
@GitterIRCbot
[irc] <uskerine> so if I want to add a column to a DataFrame where I will later fill in DateTime objects in a foreach loop, what shall I do?
[irc] <uskerine> df[!, :TS] .= DateTime() does not work