g | x | w | all
Bytes Lang Time Link
042APL Dyalog Unicode241022T123050ZVen
069JavaScript241022T100958ZShaggy
013Japt m201002T094752ZShaggy
127C#170526T090202ZMormegil
177Rockstar201002T094943ZShaggy
122QBasic180919T040858ZDLosc
133Python 2170525T144945Zhyper-ne
121PowerShell 3+170526T123946ZMatt
079Haskell170525T231246ZQuelklef
130F#170526T124439ZBrunner
070Perl 6170525T211810ZSean
018Jelly170526T000328Zfireflam
nanRuby 2.4170526T001210ZValue In
091Python 2170525T210012Zovs
00505AB1E170525T144736ZEmigna

APL (Dyalog Unicode), 42 bytesSBCS

{{1=⍴⍵:2=0+.=(⍳⍵)|⍵⋄+/⍵}¨⍵⊆⍨(1+⍺='+')/⍳≢⍺}

Try it online!

A chunk of this answer is prime testing. This uses to partition the string into boxes of either 1 or 2 numbers, then maps these numbers into either their primeness, or sums them.

JavaScript, 69 bytes

p=>a=>p.map(i=>(n=a[x++],i<a)?n+a[x++]:!(g=d=>n%--d?g(d):d-1)(n),x=0)

Try it online!

Japt -m, 15 13 bytes

Takes the programme as a character array, outputs true or false for the prime test.

ø²?Vv j:Vv2 x

Try it

ø²?Vv j:Vv2 x     :Implicit map of each character in the first input array
ø                 :Contains?
 ²                :  "p"
  ?               :If so
   V              :  Second input array
    v             :  Pop first element, mutating V
      j           :  Is prime?
       :          :Else
        Vv2       :  Pop first 2 elements of V
            x     :  reduce by addition

C#, 130 129 127 bytes

p=>d=>{var i=0;p.Any(c=>{Console.Write((c<44?d[i++]+d[i]:Enumerable.Range(2,d[i]-2).Any(x=>d[i]%x<1)?0:1)+" ");return++i<0;});}

Try it online!

Rockstar, 206 197 177 bytes

Outputs 0 for composites and -0.5 for primes

listen to S
cut S
while S
listen to N
if roll S's "+"
listen to I
say N-I/-1
else
let D be N
let P be N-1
while P and D-2
let D be-1
let M be N/D
turn M up
let P be N/D-M

say P

Try it here (Code will need to be pasted in, with the programme as the first line of input and each integer on its own line)

QBasic, 122 bytes

INPUT p$
FOR i=1TO LEN(p$)
INPUT x
IF"+"=MID$(p$,i,1)THEN INPUT y:?x+y:ELSE f=0:FOR j=2TO x:f=f-(x MOD j=0):NEXT:?f=1
NEXT

Takes the code as a line of input, then takes each input number on its own line. The outputs are interspersed with the inputs because they're printed as soon as they're calculated. The truthy value is -1; falsey is 0.

Python 2, 135 133 bytes

l,p=input()
i=j=0
while len(l)-i:print(int(all(l[i]%k for k in range(2,l[i])))if p[j]=='p'else l[i]+l[i+1]);i+=1+'p+'.find(p[j]);j+=1

-2 bytes thanks to kundor

PowerShell 3+, 151 121 Bytes

$r,$v=$args;$p={0-notin((2..(($n=0+"$args")-1)|%{$n%$_}))};$i=0;$r|%{if($_-eq"p"){&p $v[$i]}else{$v[$i]+$v[($i+=1)]}$i++}

PowerShell has no prime built-ins so I had to roll my own. My first version was terrible and I took from most of the other ones that test for 0 among modulus results which saves a lot. Also sabed a few bytes by using -notin instead of -notcontains but it mean PowerShell v2 is out.

Comment based explanation

# $r is the program code. Assumed char array
# $v is the remaining variables in an assumed integer array.
$r,$v=$args
# Anonymous function to determine if a number is a prime or not.
# Test all potential factors. Check if any 0 modulus remainders are present
$p={0-notin((2..(($n=0+"$args")-1)|%{$n%$_}))}
# $i is an index for tracking location in $v
$i=0
# Cycle each of the instructions
$r|%{if($_-eq"p"){
        # Call the prime checking anonymous function on this number
        &p $v[$i]
    }else{
        # Add the next two numbers. Adjust the index accordingly. 
        $v[$i]+$v[($i+=1)]
        
    }
    # Next number in list. 
    $i++  
}
    # Next number in list. 
    $i++  
}

Haskell, 88 79 bytes

('+':r)!(a:b:c)=a+b:r!c
('p':r)!(a:c)=min(foldr((*).mod a)1[2..a-1])1:r!c
_!e=e

"commands" ! [args] for use.

I'm still learning Haskell; golfing tips appreciated!

F#, 130 bytes

let rec r=function|[],_->()|'+'::t,f::s::u->printf"%i "(f+s);r(t,u)|_::t,n::u->printf"%b "(List.exists((%)n>>(=)0)[2..n-1]);r(t,u)

Try it online!

Perl 6, 70 bytes

{@^b.rotor($^a.comb.map(1+(*ne'p'))).map({$_-2??.[0].is-prime!!.sum})}

First the rotor method is used to split the input list into chunks of size 1 or 2 depending on whether the next character of the program is p or not. Then that chunked list is mapped over; chunks of size 2 are summed, and chunks of size 1 have their sole element tested for primality.

Jelly, 18 bytes

ÆP,+/ị@L
OḂ‘Bṁ@Ç€K

Try it online!

Alternate solution, 18 bytes

⁴Ḣ
¢+¢µ¢ÆPµḂ?
OÇ€K

Try this one online!

Ruby 2.4, 77+7 = 84 bytes

Uses the -rprime flag.

->g,i{g.chars.map{|c|c==?p?i.shift.prime?? 1:0: c==?+?i.shift(2).sum: p}-[p]}

Python 2, 91 bytes

p,i=input()
for c in p:n=i.pop(0);print all(n%k for k in range(2,n))if c>'+'else n+i.pop(0)

Try it online!

05AB1E, 5 bytes

vy.V,

Try it online!

Explanation

This challenge fit 05AB1E like a glove :)

vy      # for each instruction in the program
  .V    # execute as 05AB1E code
    ,   # print