# Use another function in the same module

**URL:** <https://discourse.julialang.org/t/use-another-function-in-the-same-module/26318>\
**Category:** New to Julia\
**Tags:** question, module\
**Created:** [July 13, 2019, 9:45am UTC](https://discourse.julialang.org/t/use-another-function-in-the-same-module/26318 "2019-07-13T09:45:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![POKIN\_CHAN](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pokin_chan/32/9309_2.png) [@POKIN\_CHAN](https://discourse.julialang.org/u/POKIN_CHAN)\
**Post date:** [July 13, 2019, 9:45am UTC](https://discourse.julialang.org/t/use-another-function-in-the-same-module/26318/1 "2019-07-13T09:45:49Z")

</div>

```julia
module ABC
  function F_1(a:Int,b:Int)
    return a + b  
  end

  function F_2(c:Int, d:Int)
    result = F_1(c+3,d+c)
    return result
  end 
end

```

e.g. Main.ABC.F\_2(3,4) will have an error because F\_1 cannot be called in F\_2. Any suggestions that using another function inside a function within the same module? Thanks

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 13, 2019, 9:57am UTC](https://discourse.julialang.org/t/use-another-function-in-the-same-module/26318/2 "2019-07-13T09:57:35Z")

</div>

the trait of your function is wrong, `:` =\> `::`

```julia
julia> module ABC
         function F_1(a::Int,b::Int)
           return a + b  
         end

         function F_2(c::Int, d::Int)
           result = F_1(c+3,d+c)
           return result
         end 
       end
Main.ABC

julia> Main.ABC.F_2(3,4)
13

```

---

<div class="post-metadata">

**Author:** ![POKIN\_CHAN](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pokin_chan/32/9309_2.png) [@POKIN\_CHAN](https://discourse.julialang.org/u/POKIN_CHAN)\
**Post date:** [July 13, 2019, 10:18am UTC](https://discourse.julialang.org/t/use-another-function-in-the-same-module/26318/4 "2019-07-13T10:18:15Z")

</div>

Sorry for the mistakes of my example, thanks for pointing out the mistake of the trait. After correcting it, my example works.  
But I don’t know why my following case has the problem:

```julia

module features_engineering
    using DataFrames
    function map_atom_info(df::DataFrame, structures::DataFrame,atom_idx::Int)
       df = join(df,structures,on = [(:molecule_name,:molecule_name),(Symbol("atom_index_$(atom_idx)"), :atom_index)],kind = :outer)
       delete!(df,"atom_idx")
       rename!(df, Dict(:atom =>Symbol("atom_$atom_idx"),
                        :x => :Symbol("x_$atom_idx"),
                        :y => Symbol("y_$atom_idx"),
                        :z => Symbol("z_$atom_idx")))
       return df
    end

    function distance_type_feat(train::DataFrame,test::DataFrame,structures::DataFrame)
        train = map_atom_info(train,structures, 0)
        train = map_atom_info(train,structures, 1)
        test = map_atom_info(test,structures, 0)
        test = map_atom_info(test,structures, 1)

        train_p_0 = train[[:x_0,:y_0,:z_0]]
        train_p_1 = train[[:x_1, :y_1, :z_1]]
        test_p_0 = test[[:x_0, :y_0, :z_0]]
        test_p_1 = test[[:x_1, :y_1, :z_1]]

        train[:dist] = norm(train_p_0 - train_p_1)
        test[:dist] = norm(test_p_0 - test_p_1)
        train[:dist_x] = (train[:x_0] - train[:x_1]) ^ 2
        test[:dist_x] = (test[:x_0] - test[:x_1]) ^ 2
        train[:dist_y] = (train[:y_0] - train[:y_1]) ^ 2
        test[:dist_y] = (test[:y_0] - test[:y_1]) ^ 2
        train[:dist_z] = (train[:z_0] - train[:z_1]) ^ 2
        test[:dist_z] = (test[:z_0] - test[:z_1]) ^ 2

        function substring_(x::String,i::Int)
            if i==1
                return string(x[1])
            elseif i==2
                return x[2:end]
            else
                return "NA"
            end
        end

        train[:type_0] = substring_.(train[:type],1)
        test[:type_0] = substring_.(test[:type],1)
        train[:type_1] = substring_.(train[:type],2)
        test[:type_1] = substring_.(test[:type],2)
        return train,test
    end
end

```

MethodError: no method matching join(::DataFrame, ::Tuple{Symbol,Symbol}; on=(:molecule\_name, :molecule\_name), kind=:outer)  
Closest candidates are:  
join(::Any, ::Any) at strings/io.jl:277 got unsupported keyword arguments “on”, “kind”  
join(::Any, ::Any, !Matched::Any) at strings/io.jl:278 got unsupported keyword arguments “on”, “kind”  
join(!Matched::IO, ::Any) at strings/io.jl:269 got unsupported keyword arguments “on”, “kind”  
…  
map\_atom\_info(::DataFrame, ::DataFrame, ::Int64) at PMP\_20190708.jl:17  
distance\_type\_feat(::DataFrame, ::DataFrame, ::DataFrame) at PMP\_20190708.jl:27  
top-level scope at none:0

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 13, 2019, 11:19am UTC](https://discourse.julialang.org/t/use-another-function-in-the-same-module/26318/5 "2019-07-13T11:19:03Z")

</div>

it says, there’s no keyword `kind` for the `.join()` function, where are you getting this usage of the function?

---

<div class="post-metadata">

**Author:** ![POKIN\_CHAN](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pokin_chan/32/9309_2.png) [@POKIN\_CHAN](https://discourse.julialang.org/u/POKIN_CHAN)\
**Post date:** [July 13, 2019, 11:27am UTC](https://discourse.julialang.org/t/use-another-function-in-the-same-module/26318/6 "2019-07-13T11:27:01Z")

</div>

I should have used “join” function improperly. Anyway this is out of scope of the question. Your first response has been the solution of the question already.
