• Home
  • About
    • Home x Work photo

      Home x Work

      Jianxu Chen's personal website and blogs

    • Learn More
    • Email
    • LinkedIn
    • Instagram
    • Github
  • Posts
    • All Posts
    • All Tags
  • Research
  • Publication

Unpack Function

15 Apr 2016

Reading time ~1 minute

When using torch, you may encounter the function “unpack” in the code of quite a lot of packages. I am really curious about what it is, because I didn’t find its definition as a Torch function.

I finally found it as function in Lua. See this.

In short,

An important use for unpack is in a generic call mechanism. A generic call mechanism allows you to call any function, with any arguments, dynamically.

One example is

f = string.find

a = {“hello”, “ll”}

f(unpack(a)) will return 3 and 4



Torch 7Deep Learning Programming Like Tweet +1