[Question]
  [
You must take two lists of positive integers as input, let's call these **n** and **m**. 
You may assume that:
* All integers in **n** are part of **m**
* All integers in **m** are unique
* The lists are non-empty
### Challenge: Return the indices of where you find the values in **n**, in **m**.
That might be confusing, but I think the test cases will make the task pretty clear. The examples are 1-indexed, you may choose 0-indexed if you want to (please specify).
```
n = 5 3 4 1
m = 6 8 4 1 2 5 3 100
output: 6 7 3 4    // 5 is in the 6th position of m 
                   // 3 is in the 7th position of m
                   // 4 is in the 3rd position of m
                   // 1 is in the 4th position of m
n = 5 3 4 9 7 5 7
m = 3 4 5 7 9
output: 3 1 2 5 4 3 4
n = 1 2 3 4 5 6
m = 1 2 3 4 5 6
output: 1 2 3 4 5 6
n = 16 27 18 12 6 26 11 24 26 20 2 8 7 12 5 22 22 2 17 4
m = 15 18 11 16 14 20 37 38 6 36 8 32 21 2 31 22 33 4 1 35 3 25 9 30 26 39 5 23 29 10 13 12 7 19 24 17 34 27 40 28
output: 4 38 2 32 9 25 3 35 25 6 14 11 33 32 27 16 16 14 36 18
n = 54
m = 54
output: 1
```
**The winners will be the shortest solutions in each language.** 
---
[This](https://codegolf.meta.stackexchange.com/a/10132/31516) is a very nice meta-post by the way!
  
[Answer]
# [V](https://github.com/DJMcMayhem/V), 26 bytes
```
jòdf kÄ/-
DÓÓ
ÒC1@"Gòdk
```
[Try it online!](https://tio.run/nexus/v#@591eFNKmkL24RZ9IV0ul8OTD0/mOjyJ0dlQ2kHJHSiV/f@/mYGChYKJgqGCkYKpgrGCoYGBAheIARICAA "V – TIO Nexus")
This is a very strange and hacky solution, because V has little to no concept of numbers. Input comes in this format:
```
6 8 4 1 2 5 3 100 
5 3 4 1 
```
With a trailing space on each line.
Hexdump:
```
00000000: 6af2 6466 206b c42f 122d 0a44 d3d3 0ad2  j.df k./.-.D....
00000010: 0143 311b 4022 47f2 646b                 .C1.@"G.dk
```
Explanation:
```
j                   " Move down one line (to N) (1)
 ò                  " Recursively:
  df                "   (d)elete until you (f)ind a space. This will be saved into
                    "   register '-' (2)
     k              "   Move up one line (to M)
      Ä             "   Duplicate line M (3)
       /<C-r>-      "   Move the cursor forward until the next occurence of register '-' 
                    "   (the number we deleted from N)
                    "   (4)
D                   "   Delete every character *after* the cursor (5)
 ÓÓ                 "   Remove everything on this line except for whitespace
Ò<C-a>              "   Replace every character on this line with `<C-a>`, which is the 
                    "   command for incrementing a number (6)
      C             "   Delete this line into register '"', and enter insert mode
       1<esc>       "   Enter a '1' and return to normal mode
             @"     "   Run register '"' as V code (7)
               G    "   Go to the last line (1)
                ò   " End recursion
                 dk " Delete the last two lines (m and n)
```
If this doesn't make it clearer, here are examples of the buffer during the various stages the loop goes through:
Stage 1 (`|` is the cursor)
```
6 8 4 1 2 5 3 100
|5 3 4 1
```
Stage 2:
```
6 8 4 1 2 5 3 100
|3 4 1
```
Stage 3:
```
|6 8 4 1 2 5 3 100
6 8 4 1 2 5 3 100
3 4 1
```
Stage 4:
```
6 8 4 1 2 |5 3 100
6 8 4 1 2 5 3 100
3 4 1
```
Stage 5:
```
6 8 4 1 2 |
6 8 4 1 2 5 3 100
3 4 1
```
Stage 6:
```
|<C-a><C-a><C-a><C-a><C-a>
6 8 4 1 2 5 3 100
3 4 1
```
Stage 7:
```
|6
6 8 4 1 2 5 3 100
3 4 1
```
Back to stage 1:
```
6
6 8 4 1 2 5 3 100
|3 4 1
```
[Answer]
# [Python 2](https://docs.python.org/2/), 25 bytes
```
lambda a,b:map(a.index,b)
```
[Try it online!](https://tio.run/nexus/python2#S7ON@Z@TmJuUkqiQqJNklZtYoJGol5mXklqhk6T5v6AoM69EI00j2kzHQsdEx1DHSMdUx1jH0MAgVicaxAKKxWpq/gcA "Python 2 – TIO Nexus")
Note that this uses 0-indexing.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 1 byte
```
⍳
```
[Try it online!](https://tio.run/nexus/apl-dyalog#@@/4qG3Co97N//@bKVgomCgYKhgpmCoYKxgaGCg4gllAMQA "APL (Dyalog Unicode) – TIO Nexus")
Note: the `⍳` function does **not** take scalars as its left argument, so to give it a left argument like `54`, you have to make it into an array using `,` like so `(,54)`.
[Answer]
## Mathematica, 25 bytes
```
#&@@@PositionIndex@#/@#2&
```
Takes two inputs `m` and `n`, and returns the 1-based indices of `n` in `m`.
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~32~~ ~~31~~ 30 bytes
1 byte saved thanks to Kritixi Lithos and 1 byte thanks to Martin Ender
```
(\d+)(?=.*¶(\d+ )*\1 )
$#2
G1`
```
Uses 0-indexing. Input has a trailing space on each line.
[Try it online!](https://tio.run/nexus/retina#HY49DsJQDIP3nsISDH1FQs/x@x0QI5fowMAZOQAXK0mlDFbiz86x7p9bWp@P@/b7hkbadiIt14stL76Pgw3WwQEaXDaQsBLCMgwDPS4VZueAHQUL64kQjrOEVR0anqDmjNzpMRADkhwhVCFYxYRy5GtGrK8mmEFFj5fNqPcWlXisuHXgDw "Retina – TIO Nexus")
**Explanation**
```
(\d+)(?=.*¶(\d+ )*\1 )
$#2
```
Here we replace every number on the first line by the number of numbers before the same number on the second line.
```
G1`
```
Then, we delete the second line, leaving only the new first line as the output.
[Answer]
# [Java](http://openjdk.java.net/), ~~104~~ 81 bytes
1 byte thanks to Business cat.
```
void f(int[]a,int[]b){for(int i=0,j=0;i<b.length;)j=a[j++]==b[i]?0*(b[i++]=j):j;}
```
[Try it online!](https://tio.run/nexus/java-openjdk#VY9NbsMgEIXXzSlYQjNCpD9RVBdVPUBWWVpeQGo7IIItGCeKLJ/dBbubrp7mzZv5ZvpBO3MmZ6diJEdl/DjfOvNDGmo8lpWCRTQbmy5kixgpwEpRmE/NXe1bvBTMSlXa7baSUpem@hLPNGmuLfuwxTT3KySiwiTL/mtC0RMG49tECW1k4@ZpRRJJfH0nSzHu4QBvsIMXeIdX2AkxFX85/S@XuymXu9nMn1DGG6pAs@SdHhHrK@8G5H1iovPUqpviAxrHv0NQj8ixW@@hmqWRaTPNvw "Java (OpenJDK 8) – TIO Nexus")
[Answer]
# C#, 32 Bytes
```
(n,m)=>n.Select(i=>m.IndexOf(i))
```
This is the code as a lambda expression, so it should be valid.
The solution is with a 0 based index. I think it's pretty straigt forward how it works - it simply takes the items of n and selects the indices of the items in m.
[Answer]
# Octave, 25 bytes
```
@(n,m)([x,~]=find(n==m'))
```
[Try it online!](https://tio.run/nexus/octave#@@@gkaeTq6kRXaFTF2ublpmXopFna5urrqn5P802Ma/YmitPwVYh2lTBWMFEwVLBXMFUwTzWmisXJAgSAnIVLIECaWBj/gMA "Octave – TIO Nexus")
[Answer]
# [Haskell](https://www.haskell.org/), 32 bytes
```
a%b=[length$fst$span(/=x)b|x<-a]
```
[Try it online!](https://tio.run/nexus/haskell#@5@ommQbnZOal16SoZJWXKJSXJCYp6FvW6GZVFNho5sY@z83MTNPwVahoCgzr0RBRSHaVMdYx0THMFY12kzHAsTSMdIBiRkaGMT@BwA "Haskell – TIO Nexus") One-indexed.
Other attempts:
```
q(h:t)x|x==h=0|1>0=1+q t x;map.q
f b=map$length.fst.($b).span.(/=)
a%b=[until((==x).(b!!))(+1)0|x<-a]
a%b=[until(\y->x==b!!y)(+1)0|x<-a]
import Data.List;map.flip elemIndex
```
[Answer]
# k, 1
This is a built-in operator in `k` and uses zero-based indexing.
```
?
```
Example:
```
k)6 8 4 1 2 5 3 100 ? 5 3 4 1
5 6 2 3
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 5 bytes
```
v²yk,
```
[Try it online!](https://tio.run/nexus/05ab1e#@192aFNlts7//9GmOgrGOgomOgqGsVzRZjoKFhCOjoKRjgJEzkAnFgA "05AB1E – TIO Nexus")
```
v     # For each value in n (call it y)
 ²    # Push m
  y   # Push y
   k, # Print the 0-indexed index of y in m
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
iÐ€
```
[Try it online!](https://tio.run/nexus/jelly#@595eMKjpjX///@PNtOx0DHRMdQx0jHVMdYxNDCI/R8NYgHFYgE "Jelly – TIO Nexus")
## Specs
* Input: two arguments, the first being **m**, and the second being **n**.
* Output: one array
[Answer]
## JavaScript (ES6), 28 bytes
Takes the arrays in currying syntax `(n)(m)`. 0-indexed.
```
let f =
n=>m=>n.map(v=>m.indexOf(v))
console.log(JSON.stringify(f([5,3,4,1])([6,8,4,1,2,5,3,100])))
console.log(JSON.stringify(f([5,3,4,9,7,5,7])([3,4,5,7,9])))
console.log(JSON.stringify(f([1,2,3,4,5,6])([1,2,3,4,5,6])))
console.log(JSON.stringify(f([16,27,18,12,6,26,11,24,26,20,2,8,7,12,5,22,22,2,17,4])([15,18,11,16,14,20,37,38,6,36,8,32,21,2,31,22,33,4,1,35,3,25,9,30,26,39,5,23,29,10,13,12,7,19,24,17,34,27,40,28])))
console.log(JSON.stringify(f([54])([54])))
```
[Answer]
# [Perl 6](https://perl6.org), 31 bytes
```
->\n,\m{n.map:{m.first($_,:k)}}
```
[Try it](https://tio.run/nexus/perl6#TVBdTsJAEH7fU8yDMa2UsrtT@kMD8RA@NjFaFkNk26Y/RkPwQh7BNy6GMwsUkyadmf3@ZobOwEcclrmwX3Bf1msDy9N0VVRBYfdVaF@axd6Gm23b9d7dc7B49w@HE0Efe9P1sITJ8We3rUzn@eFbaxrv@8E//oZlbV@9WbGezPywrfu69dDPxUBeT0TLRbN7qWDiNHKxqduL3HQFnnMOCvPZmLI3ax/2AmDbAUfzqsD6AVzfcnE4VZRhDggRKGGpjiHlGrSbKilFPfTN0C@oj2mKQtwoGSRUJY7IPdWQjQQNkoQiehlprHsGxo70v7/S5G16IZFvAioFpTlCDIoAERdaEjIlU8VxtXYfqASis/rcsRQrqIjRmACmJIK8JhLYWSnmobsBIG@m57QaSrbAjJVplNExQCFbkV/GCcgII84WETQdF0C2USybupwOxDsyW7ItO8YunhuSp0oudz0np994jj8 "Perl 6 – TIO Nexus")
## Expanded:
```
-> \n, \m {  # pointy block lambda
  n.map: {            # map over the values in ｢n｣
    m.first( $_, :k ) # return the key ｢:k｣ of the first occurrence
  }
}
```
0 indexed
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 4 bytes
```
m!bV
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.4&code=bSFiVg==&input=WzUgMyA0IDFdCls2IDggNCAxIDIgNSAzIDEwMF0=)
### Explanation
There's not much to explain here, but it shows off an interesting feature of Japt. Normally, you would pass a function to `m`, like so:
```
mX{VbX}
```
This is basically `U.map(X => V.indexOf(X))` (the `U` is implicit). However, when you're just performing one operation between two values (`b` here, on `V` and `X`), you can just give the operator and the other value and Japt will make a function out of it. This means `mX{X+2}` can be golfed to `m+2`.
However, this doesn't work when the values are in the wrong order (`mbV` would be short for `mX{XbV}`). To get around this, you can prepend an exclamation mark to the operator, which tells Japt to swap the operands. This costs an extra byte, but it's still a couple bytes shorter than the alternative. And now you know a little more about Japt.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 2 bytes
```
&m
```
This uses 1-indexing. [Try it online!](https://tio.run/nexus/matl#HY6xDcQwDAP7n@Kqr03Rju1Zgozw@5d@KYAKQiJ5Ot/fObcuYqKFgpQXEtFLRCNYzLoMIt5Bk/58bo03IzKvXl5PvLLCV4ac1uzBqpRNR3hgYrBxK4B39eZqo4ZcoKTt4ifGvT7raV3PHw "MATL – TIO Nexus")
### Explanation
The meta-function `&` indicates that the next function will use a (function-specific) secondary default in/out specification. For function `m` (`ismember`), `&` specifies that its second output will be produced. This contains the index of (the first occurrence of) each entry of the first input in the second input.
[Answer]
## Haskell, 34 bytes
```
n#m=[i|a<-n,(i,e)<-zip[1..]m,e==a]
```
Usage example: `[5,3,4,9,7,5,7] # [3,4,5,7,9]` -> `[3,1,2,5,4,3,4]`
The built-in `elemIndex` is in `Data.List` and therefore longer than the version above. The outer loop goes through `n` and the inner loop through pairs of `(i,e)` where `i` is the index of `e` in `m`. Keep the `i` where `e` equals the current element of `n`. 
[Answer]
# R, ~~20~~ 5 bytes
1-indexed; `match` is the builtin function that finds the indices in the second input of the elements of the first, i.e., `match(n,m)` gives the desired answer
```
match
```
thanks to @flodel for pointing out that returning a function is perfectly acceptable as an answer!
[Try it online!](https://tio.run/nexus/r#HY4xDsMgEAT7vIIyljZS9gBDpHwmcpPGrvJ/Z84Spxv2GOA83o/t7lUx5CmHwFW2oiXEU6GpkZOuiGvJQ2257ZfaL88qXovcCkpRHdQsIqoUVIOJKTBb9lrEeXa1U4RdLwA/UoTJIwegiQ0bk9tNFGnnS/kqvaU5@djnt33vh/blPP8)
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 4 bytes
```
xLQE
```
[Try it online!](http://pyth.herokuapp.com/?code=xLQE&input=%5B6%2C8%2C4%2C1%2C2%2C5%2C3%2C100%5D%0A%5B5%2C3%2C4%2C1%5D&debug=0)
Note that this uses 0-indexing.
[Answer]
# [J](http://jsoftware.com/), 2 bytes
```
i.
```
This is not a complete program, but a built-in function.
Use it as such:
```
echo 6 8 4 1 2 5 3 100 i. 5 3 4 1
```
[Try it online!](https://tio.run/nexus/j#@5@anJGvYKZgoWCiYKhgpGCqYKxgaGCgkKkHZgIF//8HAA)
Note that this uses 0-indexing.
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 4 bytes
```
{f#}
```
Anonymous block that expects arguments on the stack and leaves the result on the stack.
Uses 0-indexing.
[Try it online!](https://tio.run/nexus/cjam#K6z7X52mXPu/ruB/tKmCsYKJgqWCuYKpgnmsQjSIB2QpWMYCAA "CJam – TIO Nexus")
[Answer]
## Haskell, 43 bytes
```
a*b=[[fst x|x<-zip[0..]b,y==snd x]!!0|y<-a]
```
```
a*b=                                         -- define function * with 2 args
    [                                |y<-a]  -- for each elt in first arg
               zip[0..]b                     -- match elts in second arg w/ idxs
                                             -- [a,b,c] -> [[0,a],[1,b],[2,c]]
     [fst x|x<-                  ]           -- take first element in each pair
                        ,y==snd x            -- if the index matches
                                  !!0        -- first element (always only 1)
```
[Answer]
## Clojure, 25 bytes
```
#(map(zipmap %2(range))%)
```
0-indexed.
[Answer]
# Perl 5, ~~38~~ 34 bytes
4 bytes saved thanks to Dada
```
sub{map$x{$_}//($x{$_}=++$x)x0,@_}
```
1-indexed. Takes the lists **m** and **n** as a single list, like `f(@m,@n)`. The `x0` is just to keep the output from starting with `1,2,3,4,5`, etc.
[Answer]
# PHP, 56 Bytes
[Online Versions](http://sandbox.onlinephpfunctions.com/code/177bee277201e7015aeb5bb84f69db6805bddde4)
0 Indexing
output as String
```
<?foreach($_GET[0]as$v)echo" ".array_flip($_GET[1])[$v];
```
## PHP, 65 Bytes
Output as array
```
<?foreach($_GET[0]as$v)$r[]=array_flip($_GET[1])[$v];print_r($r);
```
PHP, 78 Bytes
workaround with `array_map`
```
<?print_r(array_map(function($v){return array_flip($_GET[1])[$v];},$_GET[0]));
```
for not unique arrays replace with `array_flip($_GET[1])[$v]` `array_search($v,$_GET[1])`
[Answer]
# [Uiua](https://uiua.org), 1 [byte](https://codegolf.stackexchange.com/a/265917/97916)
```
⊗
```
[Try it!](https://uiua.org/pad?src=0_2_0__4oqXWzUgMyA0IDFdWzYgOCA0IDEgMiA1IDMgMTAwXQriipdbNSAzIDQgOSA3IDUgN11bMyA0IDUgNyA5XQriipdbNTRdWzU0XQo=)
0-indexed.
[Answer]
# Bash + coreutils, 51
```
for n in $1
do grep -wn $n <<<"$2"
done|cut -d: -f1
```
[Try it online](https://tio.run/nexus/bash#bVHLboMwELzzFSOXKCESEmubl5v8SS5VAmkOmAioekjz7XTXSaWowkLyMp7Z8XjbTXKb236Ax8UjpujU4zw0V6Tf/Oux2@1UrBXDvvk5fk1ITw5pS/M9ikQ2NeN0/BgbUascBhbkClSyQ0MQyjKFQ4R/68muUTKrdFLzjnqRK70ejMK91MvcAroEVSANLgsQK6wUOmNpxSYkN9M6fKAS1lEeFARWkxWmKWEqbmAkjWFi8CXRmBATRhLonCOYTNqbWroyVHNmkBEb9qrFnU2MlXtZplbL72FdbtU7Tn0483sV3/6ed@W2dxXg7hV@27on3Bw/e5bwxLp93AWohYo31@Hipxbr1Xjwax5oohbQLnkMeP4F).
---
Previous answer:
```
s()(sort -$1k2)
nl|s|join -j2 - <(nl<<<"$1"|s)|s n|cut -d\  -f3
```
[Try it online](https://tio.run/nexus/bash#bZDNbsIwEITveYqRG0SCFClrO39u@iZcKkgEFJwKpyfCs9PdlEoIYVnyavzNjtd9kl5uIUmTMJxHZDF96TTyxylMh2HvkR00MrSJP7Ztq2JSU0inAD9tfpjeroGsN7drFPXDGWMXxs1n6MBGVcDAglyJWk5oiEJ5rrCO8LTudIOKqcpJzSeal6z0@iNK91C/ZkvoClSDNLgsQeywUuicrTWHkLxM63mDKlhHxewgsJuskKaCqbmBkWkMg3MuicfMY8LIBLrgEUwu7U0jXVlqeGaQkRjOaiSdQ4yVd1lG69f/YV1h1Tu2w3znP1R8@f/ehVtd1SyfHuW3lbvL3WY3sCX2DMSnWfo@7/3YY7kIa78E30zooeLkST@lKtoOvrv9Ag).
[Answer]
# Java 7, 80 bytes
```
void c(int[]a,java.util.List b){for(int i=0;i<a.length;a[i]=b.indexOf(a[i++]));}
```
0-indexed
**Explanation:**
```
void c(int[]a,java.util.List b){  // Method with integer-array and List parameters
  for(int i=0;i<a.length;         //  Loop over the integer-array
    a[i]=b.indexOf(a[i++])        //   And change every value to the index of the List
  );                              //  End of loop (no body)
}                                 // End of method
```
**Test code:**
[Try it here.](https://tio.run/nexus/java-openjdk#rZLBb4IwFMbv/hXvCLFpKAWFMA@7b9nBo@FQEV0XLAaqwxj@dtf24ZYsjmTLDiW0vPd9v68PuT/UjYY3cRL0qGVFH5tGnNtsUlSibeH5MgFotdCygOuplhsoPKn0Khfkq@VJthrW/mVbN/YjyEWQyQdBq1Lt9GsmVjJfrKlUm7J72XpmO53mvp/1V4DDcV0Z6cHBGeyFVN5SN1LtVjkI3xIAOFPoYAGqfMfdBWICnEBEgEGfubLC6whgBCpaC@bNCCRYRCAkQw8LAkPgWpbnVpd7Wh81PRhTXSlvENA1YnjdrdY9foJICcyd/nyEBktjV5r@FuGePab6lJ2NeH8v/dMN3GUwdxyaQMxcNDMWdmsWs4YRvoeBM09ccIZzCMNhmRNzGo2hx4O6kbRuLEJJbvp44hw5DppbwSEpQ33Ob/PnOKwwdtPiAbLxFHHsl9T@G2ZxpLSwKaawiDzCoJHtTP7t/uKx6HH0e59@0l8/AA)
```
import java.util.Arrays;
class M{
  static void c(int[]a,java.util.List b){for(int i=0;i<a.length;a[i]=b.indexOf(a[i++]));}
  public static void main(String[] a){
    int[] x = new int[]{ 5, 3, 4, 1 };
    c(x, Arrays.asList(6, 8, 4, 1, 2, 5, 3, 100));
    System.out.println(Arrays.toString(x));
    
    x = new int[]{ 5, 3, 4, 9, 7, 5, 7 };
    c(x, Arrays.asList(3, 4, 5, 7, 9));
    System.out.println(Arrays.toString(x));
    x = new int[]{ 1, 2, 3, 4, 5, 6 };
    c(x, Arrays.asList(1, 2, 3, 4, 5, 6));
    System.out.println(Arrays.toString(x));
    
    x = new int[]{ 16, 27, 18, 12, 6, 26, 11, 24, 26, 20, 2, 8, 7, 12, 5, 22, 22, 2, 17, 4 };
    c(x, Arrays.asList(15, 18, 11, 16, 14, 20, 37, 38, 6, 36, 8, 32, 21, 2, 31, 22, 33, 4, 1, 35, 3, 25, 9, 30, 26, 39, 5, 23, 29, 10, 13, 12, 7, 19, 24, 17, 34, 27, 40, 28));
    System.out.println(Arrays.toString(x));
    
    x = new int[]{ 54 };
    c(x, Arrays.asList(54));
    System.out.println(Arrays.toString(x));
  }
}
```
**Output:**
```
[5, 6, 2, 3]
[2, 0, 1, 4, 3, 2, 3]
[0, 1, 2, 3, 4, 5]
[3, 37, 1, 31, 8, 24, 2, 34, 24, 5, 13, 10, 32, 31, 26, 15, 15, 13, 35, 17]
[0]
```
]