# Calling a function

**URL:** https://discourse.julialang.org/t/calling-a-function/48875
**Category:** General Usage
**Tags:** package
**Created:** [October 23, 2020, 11:20am UTC](https://discourse.julialang.org/t/calling-a-function/48875 "2020-10-23T11:20:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Hrishikesh\_Das](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hrishikesh_das/32/18408_2.png) [@Hrishikesh\_Das](https://discourse.julialang.org/u/Hrishikesh_Das)
#### Post date: [October 23, 2020, 11:20am UTC](https://discourse.julialang.org/t/calling-a-function/48875/1 "2020-10-23T11:20:54Z")

</div>

I am trying to call a function. I have installed the package JuAFEM. The function file is already there.

[https://github.com/KristofferC/JuAFEM.jl/blob/master/src/Grid/grid\_generators.jl](https://github.com/KristofferC/JuAFEM.jl/blob/master/src/Grid/grid_generators.jl)

My code

using JuAFEM

generate\_grid(Quadrilateral, (4,5), [0.0,0.0], [1.0,0.0], [1.0,1.0], [0.0,1.0])

But it shows

MethodError: no method matching generate\_grid(::Type{Cell{2,4,4}}, ::Tuple{Int64,Int64}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1})

Can somebody help?

---

<div class="post-metadata">

### Author: ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)
#### Post date: [October 23, 2020, 11:41am UTC](https://discourse.julialang.org/t/calling-a-function/48875/2 "2020-10-23T11:41:52Z")

</div>

Looks like you’re passing in the type name `Quadrilateral` and you need to be passing in an instance of that type.

---

<div class="post-metadata">

### Author: ![Hrishikesh\_Das](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hrishikesh_das/32/18408_2.png) [@Hrishikesh\_Das](https://discourse.julialang.org/u/Hrishikesh_Das)
#### Post date: [October 23, 2020, 11:49am UTC](https://discourse.julialang.org/t/calling-a-function/48875/3 "2020-10-23T11:49:51Z")

</div>

I am new to programmning . Could you please explain?

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [October 23, 2020, 2:32pm UTC](https://discourse.julialang.org/t/calling-a-function/48875/4 "2020-10-23T14:32:54Z")

</div>

```julia
# this is the name of the struct (the definition of the type)
julia> struct MyType 
         a 
       end

# This is the generation of an instance of that type
julia> x = MyType(1)
MyType(1)

# This is a function that expects an instance of that type
julia> f( x :: MyType ) = x.a
f (generic function with 2 methods)

# Here I call the function with x, which is an instance of that type
julia> f(x)
1

# Here I call it with the name
julia> f(MyType)
ERROR: MethodError: no method matching f(::Type{MyType})
Closest candidates are:
  f(::Any, ::Any) at REPL[3]:1
  f(::MyType) at REPL[44]:1
Stacktrace:
 [1] top-level scope at REPL[46]:1

```

I have not installed that package you are using, but the error is something like that. You need to generate a `Quadrilateral` instance of some sort, and you are passing the name.

---

<div class="post-metadata">

### Author: ![kimauth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kimauth/32/25362_2.png) [@kimauth](https://discourse.julialang.org/u/kimauth)
#### Post date: [October 31, 2020, 7:19pm UTC](https://discourse.julialang.org/t/calling-a-function/48875/5 "2020-10-31T19:19:36Z")

</div>

The `generate_grid` function in 2D takes the lower left and the upper right corner as arguments. It also wants these as `Tensor`. So you would need to write

```julia
generate_grid(Quadrilateral, (4,5), Vec(0.0,0.0), Vec(1.0,1.0))

```

where Vec(0.0, 0.0) creates a 1D Tensor. E.g. in the von Mises plasticity example the grid is generated like this.
