Simpler, perhaps:

julia> foo(x) = x + 6
foo (generic function with 1 method)


julia> string(foo)
"foo"


julia> string(foos)       # just to show it's not arbitrary
ERROR: UndefVarError: foos not defined


On Friday, April 8, 2016 at 11:50:45 PM UTC-7, K leo wrote:
>
> Thanks.  I have an array for functions like funcArray=[FuncA, FuncB, 
> FuncC], and as I run them through a loop, I want to be able to tell which 
> function is running.  So perhaps just simply string(FuncA) would serve my 
> need.
>
> On Saturday, April 9, 2016 at 12:01:34 PM UTC+5:30, Tamas Papp wrote:
>>
>> julia> functionname(f)=string(f.env.name) 
>> functionname (generic function with 1 method) 
>>
>> julia> foo(x)=1 
>> foo (generic function with 1 method) 
>>
>> julia> functionname(foo) 
>> "foo" 
>>
>> But be aware that this may change and is unlikely to be a good solution 
>> unless you really, really know what you are doing. Perhaps if you 
>> explained what you want to achieve you would get suggestions for better 
>> solutions. 
>>
>> Best, 
>>
>> Tamas 
>>
>>
>> On Sat, Apr 09 2016, K. leo wrote: 
>>
>> > Say a function is named FuncA.  I hope to get this name into a string 
>> like 
>> > "FuncA".  Is there a way to do that? 
>>
>>

Reply via email to