text:
Who's that probability distribution?
Introduction
In this challenge, you are given a list of nonnegative floating point numbers drawn independently from some probability distribution.
Your task is to infer that distribution from the numbers.
To make the challenge feasible, you only have five distributions to choose from.

U, the uniform distribution on the interval [0,1].
T, the triangular distribution on the interval [0,1] with mode c = 1/2.
B, the beta distribution on the interval [0,1] with parameters α = β = 1/2.
E, the exponential distribution on the interval [0,∞) with rate λ = 2.
G, the gamma distribution on the interval [0,∞) with parameters k = 3 and θ = 1/6.

Note that all of the above distributions have mean exactly 1/2.
The Task
Your input is an array of nonnegative floating point numbers, of length between 75 and 100 inclusive.
Your output shall be one of the letters UTBEG, based on which of the above distributions you guess the numbers are drawn from.
Rules and Scoring
You can give either a full program or a function.
Standard loopholes are disallowed.
In this repository, there are five text files, one for each distribution, each exactly 100 lines long.
Each line contains a comma-delimited list of 75 to 100 floats drawn independently from the distribution and truncated to 7 digits after the decimal point.
You can modify the delimiters to match your language's native array format.
To qualify as an answer, your program should correctly classify at least 50 lists from each file.
The score of a valid answer is byte count + total number of misclassified lists.
The lowest score wins.

I probably should have asked earlier, but how much optimization towards the test cases is expected? I'm at a point where I can improve my score by tweaking a few parameters, but the impact on the score will probably depend on the given test cases.

@Dennis You can optimize as much as you want, the test cases are a fixed part of the challenge.

Y U NO Student-t distribution? =(

I really like this question. Now I wish there were a dozen more probability distributions to choose between.

Julia, 60 62 bytes + 25 2 errors = 82 64
k->"EGTBU"[(V=std(k);any(k.>1)?V>.34?1:2:V<.236?3:V>.315?4:5)]

This is fairly simple. The variance for the distributions are mostly different - it's 1/4 for exponential, 1/8 for beta, 1/12 for gamma and uniform, and 1/24 for triangular. As such, if we use variance (here done using std for standard deviation, the square root of variance) to determine the likely distribution, we only need to do more to distinguish gamma from uniform; for that, we look for a value larger than 1 (using any(k.>1)) - that said, we do the check for both exponential and gamma, as it improves overall performance.
To save a byte, indexing the string "EGTBU" is done instead of directly evaluating to a string within the conditionals.
For testing, save the txt files into a directory (keeping the names as-is), and run the Julia REPL in that directory. Then, attach the function to a name as
f=k->"EGTBU"[(V=std(k);any(k.>1)?V>.34?1:2:V<.236?3:V>.315?4:5)]

and use the following code to automate the testing (this will read from the file, convert into an array of arrays, use the function, and output for each mismatch):
m=0;for S=["B","E","G","T","U"] K=open(S*".txt");F=readcsv(K);
M=Array{Float64,1}[];for i=1:100 push!(M,filter(j->j!="",F[i,:]))end;
close(K);n=0;
for i=1:100 f(M[i])!=S[1]&&(n+=1;println(i," "S,"->",f(M[i])," ",std(M[i])))end;
println(n);m+=n;end;println(m)

Output will consist of rows containing the case that mismatched, the correct distribution -> the determined distribution, and the variance calculated (eg. 13 G->E 0.35008999281668357 means that the 13th row in G.txt, which should be a gamma distribution, is determined to be an exponential distribution, with the standard deviation being 0.35008999...)
After each file, it also outputs the number of mismatches for that file, and then at the end it also displays the total mismatches (and it should read 2 if run as above). Incidentally, it should have 1 mismatch for G.txt and 1 mismatch for U.txt

R, 202 192 184 182 162 154 bytes + 0 errors
function(x)c("U","T","B","E","G")[which.max(lapply(list(dunif(x),sapply(x,function(y)max(0,2-4*abs(.5-y))),dbeta(x,.5,.5),dexp(x,2),dgamma(x,3,6)),prod))]

This is based on the Bayesian formula P(D=d|X=x) = P(X=x|D=d)*P(D=d)/P(X=x), where D is the distribution and X is the random sample. We pick the d such that P(D=d|X=x) is greatest of the 5.
I assume a flat prior (i.e. P(D=di) = 1/5 for i in [1,5]), which means that P(D=d) in the numerator is the same in all cases (and the denominator would be the same in all cases anyways), so we can golf away everything but the P(x=X|D=d), which (except for the triangular distribution) simplify to native functions in R.
ungolfed:
function(x){
  u=prod(dunif(x))
  r=prod(sapply(x,function(y)max(0,2-4*abs(.5-y))))
  b=prod(dbeta(x,.5,.5))
  e=prod(dexp(x,2))
  g=prod(dgamma(x,3,6))
  den=.2*u+.2*r+.2*b+.2*e+.2*g
  c("U","T","B","E","G")[which.max(c(u*.2/den,r*.2/den,b*.2/den,e*.2/den,g*.2/den))]
}

Note that the ungolfed version is not exactly equivalent to the golfed version because getting rid of the denominator avoids the case of Inf/Inf which occurs if you allow the beta distribution to be over the closed interval [0,1] instead of (0,1) - as the sample data does. An additional if statement would handle that but since it's for illustrative purposes only it's probably not worth adding the complexity that is not at the heart of the algorithm.
Thanks @Alex A. for additional code reductions. Especially for which.max!

You can get this to 190 bytes by removing the line break after the opening { and the one before the closing }, and aliasing prod, e.g. P=prod, then doing P(dunif(x)), etc. The function doesn't need a name to be a valid submission, so you can remove p=. Also, excellent job. :)

You can get it to 182 using the above suggestions and using which.max(c(u,r,b,e,g)) in place of c(u,r,b,e,g)==max(c(u,r,b,e,g)).

156: function(x){c("U","T","B","E","G")[which.max(lapply(list(dunif(x),sapply(x,function(y)max(0,2-4*abs(.5-y))),dbeta(x,.5,.5),dexp(x,2),dgamma(x,3,6)),prod))]}

How dare you using R for a challenge involving statistics!!

CJam, 76
{2f*__{(z.4<},,%,4e<"UBT"="EG"\*\$-2=i3e<=}

The source code is 43 bytes long and misclassifies 33 lists.
Verification
$ count()(sort | uniq -c | sort -nr)
$ cat score.cjam
qN%{',' er[~]
  {2f*__{(z.4<},,%,4e<"UBT"="EG"\*\$-2=i3e<=}
~N}/
$ for list in U T B E G; { echo $list; cjam score.cjam < $list.txt | count; }
U
     92 U
      6 B
      2 T
T
    100 T
B
     93 B
      7 U
E
     92 E
      8 G
G
     90 G
      6 E
      3 T
      1 U

Idea
Differentiating the exponential and gamma distribution from the remaining ones is easy, since they are the only distributions that take values greater than 1.
To decide between gamma, exponential and others, we take a look at the second highest value of the sample.

If it lies in [1.5, ∞), we guess gamma.
If it lies in [1, 1.5), we guess exponential.
If it lies in  [0, 1), we have three remaining possibilities.
The remaining distributions can be differentiated by the percentage of sample values that lie close to the mean (0.5).
We divide the length of the sample by the count of values that fall in (0.3, 0.7) and take a look at the resulting quotient.

If it lies in (1, 2], we guess triangular.
If it lies in (2, 3], we guess uniform.
If it lies in (3, ∞), we guess beta.

Code
2f*    e# Multiply all sample values by 2.
__     e# Push to copies of the sample.
{      e# Filter; for each (doubled) value in the sample:
  (z   e#   Subtract 1 and apply absolute value.
  .4<  e#   Check if the result is smaller than 0.4.
},     e# If it is, keep the value.
,/     e# Count the kept values (K).
%      e# Select every Kth value form the sample, starting with the first.
,      e# Compute the length of the resulting array.
       e# This performs ceiled division of the sample length by K.
4e<    e# Truncate the quotient at 4.
"UBT"= e# Select 'T' for 2, 'U' for 3 and 'B' for 4.
"EG"\* e# Place the selected character between 'E' and 'G'.
\$     e# Sort the remaining sample.
-2=i   e# Extract the second-highest (doubled) value and cast to integer.
3e<    e# Truncate the result at 3.
=      e# Select 'E' for 3, 'G' for 2 and the character from before for 1.

Matlab, 428 328 bytes + 33 misclassified
This program is basically comparing the real CDF with an estimated one given the data, and then calculating the mean distance between those two: I think the image explains more:

The data shown in this image here shows pretty clearly that it belongs to the turquoise distribution, as it is quite close to that one, so that is basically what my program is doing. It can probably be golfed somewhat more. For me that was first of all a conceptual challenge, not very golfy.
This approach is also independent of the pdfs chosen, it would work for any set of distributions.
Following (ungolfed) code should show how it is done. The golfed version is below.
function r=p(x);
data=sort(x(1:75));
%% cumulative probability distributiosn
fu=@(x)(0<x&x<1).*x+(1<=x).*1;
ft=@(x)(0<x&x< 0.5).* 2.*x.^2+(1-2*(1-x).^2).*(0.5<=x&x<1)+(1<=x);
fb=@(x)(0<x&x<1).*2.*asin(sqrt(x))/pi+(1<=x);
fe=@(x)(0<x).*(1-exp(-2*x));
fg=@(x)(0<x).*(1-exp(-x*6).*(1+x*6+1/2*(6*x).^2));
fdata = @(x)sum(bsxfun(@le,data,x.'),2).'/length(data);
f = {fe,fg,fu,ft,fb};
str='EGUTB';
%calculate distance to the different cdfs at each datapoint
for k=1:numel(f);
dist(k) = max(abs(f{k}(x)-fdata(x)));
end;
[~,i]=min(dist);
r=str(i);
end

Fully golfed version:
function r=p(x);f={@(x)(0<x).*(1-exp(-2*x)),@(x)(0<x).*(1-exp(-x*6).*(1+x*6+18*x.^2)),@(x)(0<x&x<1).*x+(1<=x),@(x)(0<x&x<.5).*2.*x.^2+(1-2*(1-x).^2).*(.5<=x&x<1)+(1<=x),@(x)(0<x&x<1).*2.*asin(sqrt(x))/pi+(1<=x)};s='EGUTB';for k=1:5;d(k)=max(abs(f{k}(x)-sum(bsxfun(@le,x,x.'),2).'/nnz(x)));end;[~,i]=min(d(1:5-3*any(x>1)));r=s(i)

Perl, 119 bytes + 8 misclassifications = 127
I've made a tiny decision tree on three features:

$o: boolean: if any samples > 1.0
$t: count: 0-th minus 6-th 13-ile clipped into the 0-1 range,
$h: count: 0-th minus 6-th plus 12-th 13-ile clipped into the 0-1 range

Invoked with perl -F, -lane -e '...'.  I'm not sure if I should add a penalty for the non-standard parameters.  If the commas were spaces, I guess I could have gotten away without the -F,

for(@F){$b[$_*13]++;$o++if$_>1}
$h=($t=$b[0]-$b[6])+$b[12];
print$o?($t>-2?"e":"g"):($h=19?"b":"u"));
$o=@b=()

The slightly formatted output (without the -l flag) is:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
    bbbbbbbbbbbbbbbbbbbbbbbbubbbbbbbbbbbbbbbbbbbbbbb
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
    eeegeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
gggggggegggggggggggggggggggggggggggggggggggggggggggg
    gggggggggggggggggggggggggggggggggggggggggggggggg
tttttttttttttttttttttttttttttttttttttttttttttttttttt
    ttttttttttttttttttttttttttttuttttttttttttutttttt
uuuuuuuuuuuuuuuuuuuuuuuuuuutuuuuuuuuuuuuuuuubuuuuuuu
    uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuutuuuu

Python, 318 bytes + 35 missclassifications
from scipy.stats import*
from numpy import*
def f(l):
    r={'U':kstest(l,'uniform')[1],'T':kstest(l,'triang',args=(.5,))[1],'B':kstest(l,'beta',args=(.5,.5))[1],'E':kstest(l,'expon',args=(0,.5,))[1],'G':kstest(l,'gamma',args=(3,0,1/6.0))[1]}
    if sum([x>1 for x in l]): r['U'],r['T'],r['B']=0,0,0
    return max(r,key=r.get)

Idea: the distribution is guessed based on the p-value of the Kolmogorov-Smirnov test.
Test
from scipy.stats import*
from numpy import*
import os
from io import StringIO
dir=os.path.dirname(os.path.abspath(__file__))+"/random-data-master/"

def f(l):
    r={'U':kstest(l,'uniform')[1],'T':kstest(l,'triang',args=(.5,))[1],'B':kstest(l,'beta',args=(.5,.5))[1],'E':kstest(l,'expon',args=(0,.5,))[1],'G':kstest(l,'gamma',args=(3,0,1/6.0))[1]}
    if sum([x>1 for x in l]): r['U'],r['T'],r['B']=0,0,0
    return max(r,key=r.get)

U=[line.rstrip('\n').split(',') for line in open(dir+'U.txt')]
U=[[float(x) for x in r] for r in U]
T=[line.rstrip('\n').split(',') for line in open(dir+'T.txt')]
T=[[float(x) for x in r] for r in T]
B=[line.rstrip('\n').split(',') for line in open(dir+'B.txt')]
B=[[float(x) for x in r] for r in B]
E=[line.rstrip('\n').split(',') for line in open(dir+'E.txt')]
E=[[float(x) for x in r] for r in E]
G=[line.rstrip('\n').split(',') for line in open(dir+'G.txt')]
G=[[float(x) for x in r] for r in G]

i,_u,_t,_b,_e,_g=0,0,0,0,0,0
for u,t,b,e,g in zip(U,T,B,E,G):
    _u+=1 if f(u)=='U' else 0
    _t+=1 if f(t)=='T' else 0
    _b+=1 if f(b)=='B' else 0
    _e+=1 if f(e)=='E' else 0
    _g+=1 if f(g)=='G' else 0
    print f(u),f(t),f(b),f(e),f(g)
print _u,_t,_b,_e,_g,100*5-_u-_t-_b-_e-_g

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Longest Common Prefix of 2 Strings
Write a program that takes 2 strings as input, and returns the longest common prefix. This is code-golf, so the answer with the shortest amount of bytes wins.
Test Case 1:

"global" , "glossary"
"glo"

Test Case 2:

"department" , "depart"
"depart"

Test Case 3:

"glove", "dove"
""

Another good test case is "aca", "aba".

Do you want a complete programs that inputs from STDIN and prints to STDOUT, or are functions OK?

Can we assume the input won't have newlines? Which characters will the input have?

General note: People using a regex based solution should not copy other people's regex answers without testing them yourself; this does not work in all regex engines. In particular, it gives different (both incorrect) answers in nvi and vim.

All of the examples given are in lowercase, but do we need to worry about case sensitivity? For example, should global and GLOSSARY return glo or ''?

Are builtins allowed?

Can it return the length?

Python 3, 54 bytes
Thanks Python for having a built-in function for this task! :D
import os;print(os.path.commonprefix(input().split()))

Takes input as two words separated by a space such as glossary global.

Haskell, 29 bytes
(c:x)%(d:y)|c==d=c:x%y;_%_=""

Usage:
>> "global"%"glossary"
"glo"

Recursively defines the binary function % by pattern matching. On two strings with equal first letters, takes that first letters, and prepends it to the function of the remainder of the strings. On anything else, gives the empty string.

Pyth, 8 7 bytes
e@F._MQ

Thanks @isaacg for 1 byte off
Takes input quoted and comma separated, like "abc", "acc". This exits on an error (but leaves stdout empty) when the result is the empty string. If that is unacceptable, add 2 bytes for #e@F._MQq
Test Suite
Explanation
e@F._MQ        : implicit Q = eval(input)
   ._MQ        : Map the prefix operator onto both inputs
 @F            : Fold the setwise intersection operator over those lists
e              : Take the last such element, the prefixes are always made from shortest
               : to longest, so this always gives the longest matching prefix

To make the result the empty string without error: e|@F._M.z]k.

@kirbyfan64sos I believe the thing I put in about surrounding it with #...q is one byte less than that, I'll edit in the full code, I guess that is confusing

Take input in the form "abc", "def" and you can use Q instead of .z

C++, 101 100 99 bytes
#include<iostream>
int i;main(){std::string s,t;std::cin>>s>>t;for(;s[i]==t[i];std::cout<<s[i++]);}

Reads two strings from stdin, prints the character at the current position from one of the strings while the character at the current position is equal to the character at the same position in the other string.
Thanks to Zereges for saving one byte.

That is a beautiful and terrifying use of the for statement...

The loop would fail to terminate if the strings were equal.

Won't work for strings containing whitespaces. You can save one byte, by making int i in global space (so that it will be 0 initialized)

@JonTrauntvein I think that case is UB(?). It works™ for me though. (gcc-5.1)

CJam, 12 11 9 bytes
l_q.-{}#<

This reads the strings on two separate lines with Unix-style line ending, i.e., <string>\n<string>\n.
Thanks to @MartinBüttner for -1 byte, and to @jimmy23013 for -2 bytes!
Try it online in the CJam interpreter.
How it works
l_         e# Read a line (w/o trailing LF) from STDIN and push a copy.
  q        e# Read another line from STDIN (with trailing LF).
           e# The trailing linefeed makes sure that the lines are not equal.
   .-      e# Perform vectorized character subtraction. This yields 0 for equal
           e# characters, a non-zero value for two different characters, and the
           e# characters themselves (truthy) for the tail of the longer string.
     {}#   e# Find the index of the first truthy element.
        <  e# Keep that many characters from the first string.

Darn, I can't believe my very first answer was so close!

You can cheat a bit by assuming a trailing newline and use l_q.-.

@jimmy23013 That's standard for input on Unix-like OS's, so why not? Thanks!

Haskell, 38 bytes
((map fst.fst.span(uncurry(==))).).zip

Usage example: (  ((map fst.fst.span(uncurry(==))).).zip  ) "global" "glossary" -> "glo".
Zip both input string into a list of pairs of characters. Make two lists out of it: the first one with all pairs from the beginning as long as both characters are equal, the second one with all the rests. Drop the second list and extract all characters from the first list.

APL, 13
{⊃↓K/⍨=⌿K←↑⍵}

This is a function that takes an array of two strings, and returns the prefix:
      {⊃↓K/⍨=⌿K←↑⍵}'glossary' 'global'
glo
      {⊃↓K/⍨=⌿K←↑⍵}'department' 'depart'
depart

Is it really fair to say that the APL alphabet is an alphabet of byte-size characters? Or is that standard practice around here?

@Filipq Answers here use the encoding most natural to the language. APL has its own code page on which each character is a single byte.

this fails when there are matching letters after the longest common prefix, e.g. "string" "stronger" should give just "str", not "strng"

AppleScript, 215 Bytes
And I tried so hard... ;(
set x to(display dialog""default answer"")'s text returned
set a to(display dialog""default answer"")'s text returned
set n to 1
set o to""
repeat while x's item n=a's item n
set o to o&x's item n
set n to n+1
end
o
I wanted to see how well AppleScript could pull this off, and man is it not built for string comparisons.

AppleScript wasn't built for anything.

The only thing I use it for besides terrible golfs is tell app "System Events" to <something>. It is interesting to see how it deals with this kind of stuff, though. @kirbyfan64sos

sed, 18
I had something much longer and more complicated in mind, so credit for this idea goes to @kirbyfan64sos.
s/(.*).* \1.*/\1/

Includes +1 for the -r option to sed.

What was your original idea?

@kirbyfan64sos It basically involved looping through characters one by one and stopping at a mismatch.  It was just an idea - no code behind it.

C#, 201 147 bytes
using System.Linq;class a{static void Main(string[]a){a[0].Take(a[1].Length).TakeWhile((t,i)=>a[1][i]==t).ToList().ForEach(System.Console.Write);}}

I know it isn't terribly competitive. I just wanted to see what it would look like.
EDIT: Thanks Ash Burlakzenko, Berend, and Dennis_E

Just getting a C# answer under 250 bytes is competitive. Also, can't you just using System.*?

.ForEach(x=>Console.Write(x)) could be shortened to .ForEach(Console.Write)

using System.Collections.Generic; is unnecessary. Shave off one more byte by removing the space from string[] a.

1-The Contains is unnecessary. 2-You can save a few bytes by removing using System; and saying System.Console.Write; 3-This code returns the wrong result ("a") for input "aab","aaab", because of IndexOf. The shortest fix I could think of is using a[0].Take(a[1].Length) This is 147 bytes long: "using System.Linq;class a{static void Main(string[]a){a[0].Take(a[1].Length).TakeWhile((c,i)=>a[1][i]==c).ToList().ForEach(System.Console.Write);}}"

Thanks for the comments when I get a break I'll take a good look at all of them especially Dennis_E's comment.

CJam, 12 8 26
r:AAr:B.=0#_W={;;ABe<}{<}?

Try it Online.
(Got idea to use .= instead of .- after looking at Dennis's answer.)
With all the edge cases, it became to hard for a CJam beginner like me to keep it short. Hopefully, this at least works for all cases.

rs, 14 bytes
(.*).* \1.*/\1

Live demo and test cases.
This is pretty simple. It just matches the...longest common prefix and removes the rest of the string. If there is no longest common prefix, it just clears everything.

Common Lisp, 39
(lambda(a b)(subseq a 0(mismatch a b)))

Takes two string arguments, determines the index i where they differ, and returns a substring from 0 to i.

Javascript ES6, 52 bytes
f=(a,b)=>[...a].filter((e,i)=>e==b[i]?1:b='').join``

Usage:
>> f("global","glossary")
"glo"

Does not work with ada,aca...

Whoops, fixed. Forgot to kill filtering after the strings no longer match.

You don't need to name the function, so you can leave out the f=

you can do it smaller with map (a,b)=>[...a].map((e,i)=>e==b[i]?e:b='').join\``

b can be given 0 rather than ""

Perl 5, 20 19 18 bytes
19 bytes, plus 1 for the -E flag instead of -e:
say<>=~/^(.*).* \1/

This is copied shamelessly from Digital Trauma's sed answer. It assumes the input is a couple of words without spaces in them (or before the first) and with one space between them.

Update:
ThisSuitIsBlackNot suggested using -pe as follows, to save a byte (thanks!):
($_)=/^(.*).* \1/

And then Luk Storms suggested using -nE as follows to save another byte (thanks!):
say/^(.*).* \1/

(I'm counting -E as one byte instead of the standard -e, but -n or -p as two. My impression is that that's SOP around here.)

"-M5.010, when needed, is free". Per the same meta post, -pe or -ne would be 1 additional byte, not 2. So perl -nE 'say/^(.*).* \1/' would score 16 bytes.

Python 3, 72
31 bytes saved thanks to FryAmTheEggman.
8 saved thanks to DSM.
r=''
for x,y in zip(input(),input()):
 if x==y:r+=x
 else:break
print(r)

What would Python programmers do without zip? :D

@BetaDecay Our fly would be open all the time.

You could put the input()s in the zip and save the a and b binding.

@DSM Ooo, good point. Thanks!

Python 3, 47
def f(w):[print(end=c[c!=d])for c,d in zip(*w)]

A function that takes a list w of two words, and prints the common prefix before terminating with an error.
Python 3's print function lets you prints strings flush against each other with print(end=c) (thanks to Sp3000 for saving 3 bytes with this shorter syntax). This repeatedly take two letters from the words, and prints the first of the letters. The indexing c[c!=d] gives an out-of-bounds error where c!=d, terminating the execution when two unequal letters are encountered.
An explicit for loop is one char longer than the list comprehension:
def f(w):
 for c,d in zip(*w):print(end=c[c!=d])

Wow! I hadn't even thought about using a function! Nice one. +1

Only saw this now, but how about print(end=c[c!=d])?

@Sp3000 Wow, I never connected that the main argument to print being optional meant it could be called with only the end argument, and that could contain the string. That's a really useful trick in general. You should make a tip.

MATL, 11 9 bytes
y!=XdYpf)

Try it online!
(-2 bytes thanks to Giuseppe)
 y  % implicitly input the two strings, then duplicate the
    %  first one into the stack again
    %  stack: ['department' 'deported' 'department']
 !  % transpose the last string into a column vector
 =  % broadcast equality check - gives back a matrix comparing
    %  every letter in first input with the letters in the second
 Xd % diagonal of the matrix - comparison result of each letter with
    %  only corresponding letter in the other string
    %  stack: ['department' [1; 1; 1; 0; 1; 1; 0; 0;]]
 Yp % cumulative product (so only initial sequence of 1s remains
    %  1s, others become 0)
    %  stack: ['department' [1; 1; 1; 0; 0; 0; 0; 0;]]
 f  %  find the indices of the 1s
 )  % index at those elements so we get those letters out
    % (implicit) convert to string and display

Retina, 14 bytes
Uses the same idea as kirbyfan64sos. Unfortunately, despite Martin's claim that eventually Match mode will feature a way to print capturing groups, it hasn't been implemented yet. Otherwise, (.*).* \1 could be used along with 2 bytes or so for some not-yet-existing configuration string option.
(.*).* \1.*
$1

Each line would go in its own file, with 1 byte added per additional file. Alternatively, run in a single file with the -s flag.

The equivalent regex fails to match in vim due to greediness (and a non-greedy regex will match the shortest substring, i.e. blank), are you sure it works?

@Random832 Try using this regex replace tester, with the .NET option checked. Set the operation to "replace", and put the patterns in the correct boxes. It doesn't fail to match if there should be one. How could it possible fail due to greediness? That's the only reason it works. \1 ensures that both words start with the same prefix. So no matter how greedy (.*) is, \1 is the same.

In vim it refuses to match at all - I think it is finding a longer string for the first (.*), then failing to match it against \1, then not properly backtracking to shorter strings.

@Random832 Then you need to find something else to test your regexes on.

Japt, 27 bytes
Japt is a shortened version of JavaScript. Interpreter
Um$(X,Y)=>$A&&X==VgY ?X:A=P

(The strings go into the Input box like so: "global" "glossary")
This code is exactly equivalent to the following JS:
A=10;(U,V)=>U.split``.map((X,Y)=>A&&X==V[Y]?X:A="").join``

I have not yet implemented anonymous functions, which is what the $...$ is for: anything between the dollar signs is left untouched in the switch to JS. After I add functions, this 21-byte code will suffice:
UmXY{A&&X==VgY ?X:A=P

And after I implement a few more features, it will ideally be 18 bytes:
UmXY{AxX=VgY ?X:AP

Suggestions welcome!

So it turns out that this program is only 15 bytes in modern Japt:
¡A©X¥VgY ?X:A=P

Try it online!

Julia, 62 bytes
f(a,b)=(c="";for(i,j)=zip(a,b) i!=j?break:(c*=string(i))end;c)

Ungolfed:
function f(a::AbstractString, b::AbstractString)
    # Initialize an output string
    c = ""

    # Iterate over the pairs of characters in a and b,
    # truncated to the shorter of the two lengths
    for (i, j) in zip(a, b)
        if i == j
            # If they match, append to the output string
            c *= string(i)
        else
            # Otherwise stop everything!
            break
        end
    end

    return c
end

Fixed an issue (at the hefty cost of 14 bytes) thanks to xnor!

K, 24 bytes
{(+/&\=/(&/#:'x)#'x)#*x}

Find the minimum of the length of each string. ((&/#:'x)). Trim each string to that length (#'x). Then compare, smear and sum the resulting sequence:
  =/("globaa";"glossa")
1 1 1 0 0 1
  &\=/("globaa";"glossa")
1 1 1 0 0 0
  +/&\=/("globaa";"glossa")
3

Finally, take that many characters from the first of the strings provided (#*x).
In action:
 f: {(+/&\=/(&/#:'x)#'x)#*x};
 f'(("global";"glossary")
    ("department";"depart")
    ("glove";"dove")
    ("aaa";"aaaaa")
    ("identical";"identical")
    ("aca";"aba"))
("glo"
 "depart"
 ()
 "aaa"
 "identical"
 ,"a")

Powershell, 65 bytes
Compare the strings, shrinking the first until it either matches (print and exit) or the string is null and the loop terminates.
param($a,$b)while($a){if($b-like"$a*"){$a;exit}$a=$a-replace".$"}

MATLAB, 50 40 bytes
Defines a function that accepts 2 strings as input, outputs to command window
function t(a,b);a(1:find([diff(char(a,b)) 1],1)-1)

This solution will work for any string, outputs
ans =

   Empty string: 1-by-0

if no match is given.
Can be golfed by  using a script instead of a function (using local variables a, b) (-16 bytes).
so getting 34 Bytes
a(1:find([diff(char(a,b)) 1],1)-1)

The function style (which seems to be the accepted style), yields
@(a,b)a(1:find([diff(char(a,b)) 1],1)-1)

(Thanks @Stewie Griffin)

40 bytes: @(a,b)a(1:find([diff(char(a,b)) 1],1)-1). =)

C99, 73 bytes
main(int c,char *a[]){for(char *x=a[1],*y=a[2];*x==*y++;putchar(*x++));}

Similar to this answer, but shorter and meets spec (takes input from stdin).

Spec doesn't say input has to come from stdin. This is actually longer than the other answer if you add #include<stdio.h>, which is necessary for the program to compile.

@AndrewCashner - It doesn't need to be on stdin, but it does need to take input. The other answer is hard-coded.  Also, gcc whines about the implicit usage, but it compiles fine without the include.

Much shorter without the temporaries: main(int c,char**a){for(;*a[1]==*a[2]++;putchar(*a[1]++));} (59 bytes).

Perl 6, 28 bytes
I came up with two that take their values from STDIN which are based on the Perl 5 answer.
lines~~/(.*).*' '$0/;say ~$0

lines~~/:s(.*).* $0/;say ~$0

The first requires exactly one space between the inputs, while the other requires at least one whitespace character between the inputs.

That is quite a bit shorter than the first thing I tried which takes the values from the command line.
say [~] map ->($a,$b){$a eq$b&&$a||last},[Z] @*ARGS».comb # 58 bytes

or even the lambda version of it:
{[~] map ->($a,$b){$a eq$b&&$a||last},[Z] @_».comb} # 52 bytes

Though this is much easier to adjust so that it accepts any number of input strings, at the cost of only one stroke.
{[~] map ->@b {([eq] @b)&&@b[0]||last},[Z] @_».comb} # 53 bytes
#          ┗━┛ ┗━━━━━━━┛  ┗━━━┛

my &common-prefix = {[~] map ->@b {([eq] @b)&&@b[0]||last},[Z] @_».comb}

say common-prefix <department depart>; # "depart"
say common-prefix; # ""
say common-prefix <department depart depot deprecated dependant>; # "dep"

# This code does not work directly with a single argument, so you have
# to give it an itemized List or Array, containing a single element.

say common-prefix $('department',); # "department"

# another option would be to replace `@_` with `(@_,)`

05AB1E, 6 bytes
ø€ËγнÏ

Try it online or verify all test cases.
Or alternatively:
ηR.ΔÅ?

Might be invalid, since it outputs -1 instead of an empty string if the strings have no common prefix.
Try it online or verify all test cases.
Explanation:
ø      # Zip the two (implicit) inputs together, creating pairs
       #  i.e. "abc1de98f" and "abc2de87f"
       #   → ["aa","bb","cc","12","dd","ee","98","87","ff"]
 €Ë    # Check for each if all inner items (the two characters in this case) are the same
       #  → [1,1,1,0,1,1,1,0,0,1]
   γ   # Split it into parts, grouping the same subsequent values together
       #  → [[1,1,1],[0],[1,1],[0,0],[1]]
    н  # Pop and only leave the first item
       #  → [1,1,1]
     Ï # Only leave the characters at the truthy indices in the (implicit second) input
       #  i.e. "abc2de87f" and [1,1,1] → "abc"
       # (after which the result is output implicitly)

η      # Get the prefixes of the first (implicit) input
       #  i.e. "abc1de98f"
       #   → ["a","ab","abc","abc1","abc1d","abc1de","abc1de9","abc1de98","abc1de98f"]
 R     # Reverse this list
       #  → ["abc1de98f","abc1de98","abc1de9","abc1de","abc1d","abc1","abc","ab","a"]
  .Δ   # Then find the first item in this list which is truthy for:
       # (which will result in -1 if none are found)
    Å? #  Check if the second (implicit) input starts with the current prefix
       #   i.e. "abc2de87f" and "abc1d" → 0 (falsey)
       #   i.e. "abc2de87f" and "abc" → 1 (truthy)
       # (after which the result is output implicitly)

Alt 6. This one outputs [] instead of -1.

Husk, 6 4 bytes
→¤nḣ

Try it online!
-2 bytes from Dominic Van essen.

4 bytes using 'combin' (¤)...

Clojure/ClojureScript, 51
(defn f[[a & b][c & d]](if(= a c)(str a(f b d))""))

Pretty straightforward.  Unfortunately the spaces around the parameter destructuring are necessary (that's the [a & b] stuff).  Not the shortest but I beat some other answers in languages that like to brag about their terseness so I'll post it.

Python 2, 50 bytes
for a,b in zip(*input()):print(1/0if a!=b else a),

Input
The input is taken as two strings:
"global", "glossary"

Output
The output is each character followed by a space; which, hopefully, isn't a problem. However, if it is, I'll edit my answer.
g l o

I'm pretty sure this is invalid; the spec clearly gave the output format as a string without spaces.

Well yes, but the input was also given in the format "global" , "glossary" (two separate strings).. How many other answers follow that to the letter? @ThomasKwa

"takes two strings" is the language used by OP; usually when something like that is mentioned without any qualifiers, it refers to one of our default I/O, which means we can take one string from the command line and one from STDIN, or an array of two strings, or whatever else follows those rules.

I think you're taking my answer a bit too seriously. This is just a fun submission and my best attempt at beating a built-in. If OP doesn't like the output format, so be it; I'll remove my answer. @ThomasKwa

How about print(exit()if a!=b else a,end='')? I don't know if that'll work or not, but it might

Oh wait, no mine would be shorter then :D

end='' only works for Python 3 because print is a function :P @BetaDecay

Thanks! I had forgotten about STDERR. I was originally experimenting with it, but I guess it just faded away, haha. Also, there are many properly working variations, but they're all 56-61 bytes (except xnor's). @FryAmTheEggman

Yeah my other version didn't actually work, hence the deleted comment :S Anyway the 1/0 thing should work

TeaScript, 16 bytes 20
xf»l¦y[i]?1:b=0)

Takes each input separated by a space.

, 25 chars / 39 bytes
ô⟦ï0]Ă⇀$≔ï1[_]?1:ï1=0)ø⬯)

Try it here (Firefox only).
It barely looks like ES6.

Scala, 90 bytes
object S extends App{print(args(0)zip args(1)takeWhile{case(a,b)=>a==b}map(_._1)mkString)}

It takes to Strings as arguments and outputs to stdout.

This won't print a string to STDOUT, but a Vector[Tuple2[Char,Char]]

Fixed! Thanks for pointing out.

ed, sed, 19 bytes
ex, 18 bytes
vim, 20 bytes
s/\(.*\).* \1.*/\1/

This also works with ex/vi (heirloom ex 050325), and the trailing slash is not required.
Oddly, this should work in vim, but mysteriously fails. It works if I add another unused capture group, something which should not change the semantics of the regex at all:
s/\v(.*)(.* \1.*)/\1

It fails and gives garbage answers in nvi and the results are downright mysterious:
:1
global glossary
:s/\(.*\)\(.*\) \1\(.*\)/\1{\2,\3}/
global{,ry}

NOTE: This expects the words on the current [last in the file] line [or every line for the sed script] separated by a space, and containing no space. To operate on every line in ex/vim, add % to the beginning. I don't think I'm the only program here to have constraints like these.

PHP, 52 bytes
Not spectacular but does the job:
$a=$argv;while($a[1][$i]==$a[2][$i])echo$a[1][$i++];

Takes two command line arguments:
php prefix.php department depart

PHP7 lets you save another byte while(($a=$argv)[1][$i]==$a[2][$i])echo$a[1][$i++]; - Another PHP7 only solution (and best I could come up with @ 50 bytes) <?=substr(($a=$argv)[1],0,strspn($a[1]^$a[2],~ÿ)); - Make sure your editor is in ascii mode, it's important the ~ÿ does not get converted to unicode.

MATLAB, 63 bytes
Defines a function that accepts 2 strings as input.
function f(a,b),c=1;try,while a(c)==b(c),c=c+1;end,end,a(1:c-1)

Had to include a try-statement for those cases where a would be a is a longer string than b.

If we have the freedom to always supply the shorter string to a, then 8 bytes can be removed.
If it is allowed to define a and b in the workspace, then another 16 bytes can be removed.

Scala, 85 83 77 bytes
def f(a:String,b:String)=a zip b takeWhile(a=>a._1==a._2) map(_._1) mkString

for example,
f("global" , "glossary")

returns
glo

(edited: the return type is made explicit by the last "mkString" invocation)

C# 147 146
string l(string a,string b){var s="";for(int i=0;i<Math.Min(a.Length,b.Length);i++){if(a[i]==b[i])s+=a[i];else return a.Substring(0,i);}return s;}

Readable and ungolfed version
    string longestPrefix(string a, string b)
    {
        var s = "";
        for (int i = 0; i < Math.Min(a.Length, b.Length); i++)
        {
            if (a[i] == b[i]) s+=a[i];
            else return a.Substring(0, i);
        }

        return s;
    }

How it works:
It loops until characters on the same index do not match. Every character that matches is added to s string, otherwise return a new string from zero index to current iteration.

R, 130 bytes
substr(x[1],1,which.max(apply(do.call(rbind,lapply(strsplit(x,''),`length<-`,nchar(x[1]))),2,function(i)!length(unique(i))==1))-1)

Usage:
x <- c('bubblegum','bubbafish')

brainfuck, 91 bytes
+[>>,>++++[<-------->-]<]<<[<<]>+[>>++++[>++++++++<-],]<[<]>>-<[>>[<+>>-<-]+>[<->,]<[<.,]>]

Requires an interpreter that either allows negative positions on the tape or wraps if you < from 0. Also requires , to return 0 every time you use it after input runs out. (In my experience these are both the most common behaviour.) Takes input as two words separated by a space.
This was a lot easier than I expected it to be! Usually I decide to write a brainfuck program and end up devoting quite a bit of time to it, but this one played nice. My first idea ended up working well and being rather short, especially for brainfuck.
This works by getting the entire first word and storing the characters in every second cell, then weaving in the second word (e.g. gglloosbsaalr y). Then, for each pair of characters a and b, it copies a a cell to the left and simultaneously replaces b with b-a. The cell a used to be in becomes NOT (b-a). If that's true, a is printed and the loop continues to the next set of characters. Otherwise, nothing is printed and the loop terminates.
I only used two real golfing tricks in this program. The first was combining two unrelated loops while gathering input. The first word is initially stored with each of its bytes subtracted by 32, so that space becomes 0 and the loop can end. Rather than adding 32 to each of those bytes and then getting the second word, the program does both at the same time. The second trick I used was abuse of , when I know the input is empty. The idiomatic way of setting a cell to 0 is [-]. However, if you know that the program has already read the entire input, most interpreters will let you try to get a byte of input anyway and set the current cell to NUL, or 0. I use this twice in my program, saving 4 bytes.
Ungolfed:
+[>>,>++++[<-------->-]<]          get first word (minus 32 at each byte)

<<[<<]>                            go back to start

+[>>++++[>++++++++<-],]            get second word and add 32 to each byte of
                                   first word

<[<]>>-<                           go back to start and clean up a little bit

[                                  main loop

  >>[<+>>-<-]                        subtract letter from second word from
                                     letter of first word

  +>[<->,]<                          logical NOT the result

  [<.,]>                             if the result is 1: print the letter
                                     else: the loop dies and execution is
                                     terminated

]

Javascript: 67 Bytes
(a,b)=>{for(i=0;i<a.length;i++){if(a[i]!=b[i])return a.slice(0,i)}}

MUMPS, 54 bytes
t(a,b) f i=$L(a):-1:0 s p=$E(a,1,i) q:p=$E(b,1,i)
    q p

Typically primitive stuff - it just compares successively-shorter prefixes of the strings until it hits a match.

><>, 37 bytes
i:0( ?\
4*=?\$>1+{:8
+[r]\$1
?!;o>:{=

Try it online!
Input is via STDIN, and is expected without quotes, separated by a space. For example, global glossary.
After the input is read, the characters up to and including the space are reversed and pushed back onto the stack. For example, if the input were global glossary, the stack would be glossary labolg. The stack is then rotated to the left one step at a time. If the top two chars are the same, output. Otherwise, end.

Brainfuck, 61 bytes
+
[
  ,[<+> >+<-]
  ++++[>--------<-]
  >
]
<<[<]
<+
[
  ,[>+>-<<-]
  >>[<]
  <[.>]
  <
]

Expects two words separated by a space.
Try it online.

Java 8, 76 bytes
(a,b)->{String m="";for(int i=0;i<a.length&&a[i]==b[i];)m+=a[i++];return m;}

Lambda that takes 2 char[] arguments. Loops through until the letters stop matching or we match them all, appending them to a blank string as it goes.

K (oK) / K4, 21 19 bytes
Solution:
(*x)@&&\=/(#,/x)$x:

Try it online!
Explanation:
Pad strings to combined length of the strings, check for equality, find matching indices, take minimum over resulting list, and index into first element of original input at these indices.
(*x)@&&\=/(#,/x)$x: / the solution
                 x: / save input as x
                $   / pad
          (    )    / do together
            ,/x     / flatten (,/) x
           #        / count (returns length)
        =/          / compare, equals (=) over (/)
      &\            / mins, min (&) scan (\)
     &              / indices where true
    @               / index into
(  )                / do this together
 *x                 / first (*) x

Jelly, 6 bytes
¹Ƥ€f/Ṫ

Try it online!

Rust, 75 bytes
|a,b|a.chars().zip(b.chars()).take_while(|(a,b)|a==b).map(|v|v.0).collect()

Try it online!
Does unnecessary heap allocation for the result (idiomatic Rust code would return &str here as opposed to String), but it works so whatever. It's not like it matters.
This iterates over string characters as long as characters match and then collects matched characters into a String.

Kotlin, 55 bytes
Not-Lame Edition! (no builtin)
{zip(it).takeWhile{(a,b)->a==b}.fold(""){a,(f,_)->a+f}}

{zip(it)                                                 // zip first string with second
        .takeWhile{(a,b)->a==b}                          // take pairs while chars are equal
                               .fold(""){a,(f,_)->a+f}}  // fold into string

Try it online!

Japt -h, 6 bytes
®å+Ãrf

Try it

x86-16 machine code, 6 bytes
00000000  56 A6 74 FD 4E C3                                 V.t.N.

Callable function.
Expects [SI] = address of first string, [DI] = address of second string.
Outputs as: Top of stack = start of memory slice, SI = end of memory slice (like the slice in Python).
Disassembly:
56            PUSH    SI    ; Store original SI onto stack
A6      LOOP: CMPSB         ; Compare [SI++] with [DI++]
74 FD         JZ      LOOP  ; If they're equal, jump to tag 'LOOP'
4E            DEC     SI    ; -- SI
C3            RET           ; Return to caller

Example run
-d 0100
0B4A:0100  56 A6 74 FD 4E C3 00 00-00 00 00 00 00 00 00 00   V.t.N...........
0B4A:0110  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
0B4A:0120  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
0B4A:0130  67 6C 6F 62 61 6C 00 00-00 00 00 00 00 00 00 00   global..........
0B4A:0140  67 6C 6F 73 73 61 72 79-00 00 00 00 00 00 00 00   glossary........
0B4A:0150  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
0B4A:0160  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
0B4A:0170  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
-r
AX=0000  BX=0000  CX=0000  DX=0000  SP=FFEA  BP=0000  SI=0130  DI=0140
DS=0B4A  ES=0B4A  SS=0B4A  CS=0B4A  IP=0100   NV UP EI PL NZ NA PO NC
0B4A:0100 56            PUSH    SI
-t

AX=0000  BX=0000  CX=0000  DX=0000  SP=FFE8  BP=0000  SI=0130  DI=0140
DS=0B4A  ES=0B4A  SS=0B4A  CS=0B4A  IP=0101   NV UP EI PL NZ NA PO NC
0B4A:0101 A6            CMPSB
...
-t

AX=0000  BX=0000  CX=0000  DX=0000  SP=FFE8  BP=0000  SI=0133  DI=0144
DS=0B4A  ES=0B4A  SS=0B4A  CS=0B4A  IP=0105   NV UP EI PL NZ NA PE CY
0B4A:0105 C3            RET
-d ss:ffe0
0B4A:FFE0  00 00 00 00 30 01 4A 0B-AE 05 30 01 30 01 00 00   ....0.J...0.0...
0B4A:FFF0  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
-rsp
SP FFEA
:
-

Nekomata, 5 bytes
ᵃp=al

Attempt This Online!
ᵃp=al
ᵃp      Non-deterministically choose a prefix of both inputs
  =     Check if the two prefixes are equal
   al   Find the last possible solution, which is the longest

K, 45 bytes
{*|(*v)@{&y~'x}.#[&/#:'v;]'v:{#[;x]'1+!#x}'x}

Takes input as a 2-element list.

Ruby, 44 characters
->a,b{i=0;i+=1while a[i]&&a[i]==b[i];a[0,i]}

Sample run:
2.1.5 :001 > ->a,b{i=0;i+=1while a[i]&&a[i]==b[i];a[0,i]}["global , "glossary"]
 => "glo"

2.1.5 :002 > ->a,b{i=0;i+=1while a[i]&&a[i]==b[i];a[0,i]}["department", "depart"]
 => "depart"

2.1.5 :003 > ->a,b{i=0;i+=1while a[i]&&a[i]==b[i];a[0,i]}["glove", "dove"]
 => ""

Swift, 34 bytes
import UIKit
"global".commonPrefixWith("glossary")
But with Swift 2 it is actually more like:
"global".commonPrefixWithString("glossary",options:.CaseInsensitiveSearch)

C#, 112 bytes
class P{static void Main(string[]a){try{for(int i=0;a[0][i]==a[1][i];)System.Console.Write(a[0][i++]);}catch{}}}

Newlines and indentation for clarity:
class P{
    static void Main(string[]a){
        try{
            for(int i=0;a[0][i]==a[1][i];)
                System.Console.Write(a[0][i++]);
        }
        catch{}
    }
}

Minkolang 0.10, 21 bytes
(od" "=,)x(0gdo=?.O1)

Expects input as two words, space-separated, like so: department depart. Try it here.
Explanation
(od" "=,)      Loops through input until a space is encountered
x              Dumps extraneous space
(0gdo=   1)    Loops through second word and compares letters
      ?.O      Halts if two letters are not equal, outputs them otherwise

pb, 105 bytes
^w[B!32]{>}>w[B!0]{t[B]vb[1]<[X]w[B!0]{>}b[T]w[B!1]{>}b[0]^>}v<[X]<t[0]w[T=0]{>t[B]^t[T-B]v}w[B!0]{b[0]>}

Takes two words separated by a single space. (I can save a byte by using a tab instead but that feels like cheating.)
In pb, the area that can be written to is thought of as a 2D space, with (0, 0) in the upper left. Additionally, input is initially kept at Y=-1. This program copies the second word of the input to Y=0 (starting at (0, 0)). Then, each letter is compared to the letter immediately above it until one is found that doesn't match. The rest of the word is erased and the desired output is already on the canvas so it's printed when execution halts.
Ungolfed:
^w[B!32]{>}>       # Go to the first letter of the second word
w[B!0]{            # For each letter in the second word:
    t[B]             # Save the letter to T
    vb[1]            # Put a flag below that letter so it can be found later
    <[X]w[B!0]{>}    # Go to the first empty space on Y=0
    b[T]             # Write the contents of T
    w[B!1]{>}b[0]    # Go back to the flag and erase it
    ^>               # Restart loop from next letter
}

v<[X]<             # Go to (-1, 0)
t[0]               # Set T to 0
w[T=0]{            # While T is 0:
    >t[B]            # Save the next letter of the second word to T
    ^t[T-B]v         # Subtract the equivalent letter of the first word from T

    # If they were the same, T is 0 and the loop continues.
}

w[B!0]{b[0]>}      # Erase the rest of the second word

Dyalog APL, 12 bytes
{⊥⍨⌽=⌿↑⍵}↑∊

That's two bytes less than the previous APL solution!
The overall function is ↑, which takes n elements (characters) from the flattened (∊) argument, where n is the result of applying the function {⊥⍨⌽=⌿↑⍵} to the argument:
↑⍵ convert list of strings to table (padding with spaces to form rectangle)
=⌿ compare down (columns) giving boolean list
⌽ reverse
⊥⍨ count trailing trues*

*Literally it is a mixed-base to base-10 conversion, using the boolean list as both number and base:
⊥⍨0 1 0 1 1 is the same as 0 1 0 1 1⊥⍨0 1 0 1 1 which is  0×(0×1×0×1×1) 1×(1×0×1×1) 0×(0×1×1) 1×(1×1) + 1×(1) which again is two (the number of trailing 1s).

PHP, 49 bytes
<?=substr($t=$argv[1],0,strspn($t^$argv[2],"\0"));

Replace \0 with the actual byte.

Java 7, 145 bytes
class M{public static void main(String[]a){for(char i=0,c;i<a[0].length();){c=a[0].charAt(i);if(c!=a[1].charAt(i++))break;System.out.print(c);}}}

Those pesky program-requirements instead of function..
Ungolfed:
class M{
  public static void main(String[] a){
    for(char i = 0, c; i < a[0].length(); ){
      c = a[0].charAt(i);
      if(c != a[1].charAt(i++)){
        break;
      }
      System.out.print(c);
    }
  }
}

Try it here.

Pretty sure you're allowed to assume 'programs or functions' unless full program is specified by OP

see here

@Xanderhall In the description it states "Write a program that takes 2 strings as input.."

If you'd looked at the link I posted, you'd see that the community consensus is that the default for a challenge is "program or function".

@Xanderhall I know the default is program or function, but in this question the OP states it should be a program. The question rules overrules that default rule...

AFAIK, the default rule is put in place to expand the case that the question only says 'program' to include 'program and function'. Most question-makers that want a full program will explicitly specify 'full program'. It's along the same lines as the I/O rules.

05AB1E, 10 bytes
.ps.p©å®Ï¤

Try it online!

Powershell + Regex, 48 bytes
$m=$args-join"`n"-match"(^.*).*`n\1";$Matches[1]

one line input strings only.
Powershell pure, 58 56 bytes
param($a,$b)for($i=0;$a[$i]-eq$b[$i]){$c+=$a[$i++]};"$c"

Test script:
$f = {
param($a,$b)for($i=0;$a[$i]-eq$b[$i]){$c+=$a[$i++]};"$c"
}

"glo" -eq (&$f "global" "glossary")
"depart" -eq (&$f "department"  "depart")
"" -eq (&$f "glove" "dove")

Output:
True
True
True

Regex, 12 bytes
(^.*).*$\n\1

each input string is separate line. https://regex101.com/r/bTf1ud/1

C# (Visual C# Compiler), 62 bytes
(a,b)=>Concat(a.Zip(b,(x,y)=>x==y?x:'$').TakeWhile(x=>x!='$'))

Try it online!
Zip! This byte count includes only the lambda expression, and some necessary using static directives are not counted.
It is assumed that no word will contain the magical char value $ (otherwise program may fail). Can use \0 instead (but that is longer to type).

C, 59 bytes
main(int c,char**a){while(*a[1]==*a[2]++)putchar(*a[1]++);}

Input from the command-line arguments.
Note - will overrun after printing the final null character if the input strings are identical.

Zsh, 46 bytes
until [[ $1 = ${2%$~s}* ]] {s+=?;}
<<<${2%$~s}

Try it online!

Vyxal, a, 5 4 bytes
R÷ġṘ

Try it Online!
Explained
R÷ġṘ
R÷   # vectorise reverse over the input (wrapped in an array by the -a flag) and push contents onto the stack
  ġ  # Push the greatest common suffix
   Ṙ # and reverse it to get the prefix

V (vim), 41 40 bytes
qqhYp$x@qq@qo<esc>j$@qo<esc>:%!awk 'a[$0]++'
jdG

Try it online!
No regex.
Takes the strings on two separate lines. The awk command is from here.
Once the matching prefixes are found, we delete everything except the first line.

Thunno 2, 6 bytes
Z€ạġhị

Attempt This Online!
Explanation
Z€ạġhị  # Implicit input
Z       # Zip them together
 €      # To each inner pair:
  ạ     #  Check if they're equal
   ġ    # Group consecutive items
    h   # Get the first group
     ị  # Corresponding filter
        # Implicit output

Java, 152 bytes
String a="aa",b="ab";char[]c=a.toCharArray(),d=b.toCharArray();int e=0,f=Math.min(c.length,d.length);for(;e<f&&c[e]==d[e];e++);return new String(c,0,e);

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Format a Drop Capital
Introduction
Write a program or function that adds a drop capital to a paragraph. The program will input the text to format, the column width, and the number of lines to drop the capital. The drop capitals look like this:
Lines:        2     3      4
Drop capital: A|    A.|    A..|
              ~'    ..|    ...|    etc.
                    ~~'    ...|
                           ~~~'

This is a typography related challenge.
Input

Input a string of printable ASCII characters (no tabs or newlines) and 2 integers greater than one.
One integer is the number of columns that the output should have.
The other is the number of lines spanned by the drop capital.
The text string contains words separated by single spaces.
Assume none of the words will be longer than the column width.
That is, column width > longest word + drop capital height
All lines will have at least one word.
For this challenge, a word consists of any character other than a space.
Input may be in any convenient format following the rules above.

Output

A left-justified block of text containing a drop capital with the specified number of lines.
A line should contain as many words as possible without being longer than the column width.
There is a space between the drop capital and the rest of each line.
One trailing space or newline is allowed.

Examples
Lines: 2 Columns: 10 Text: The quick brown fox jumped over the lazy dog.

T| he
~' quick
brown fox
jumped
over the
lazy dog.

Lines: 3 Columns: 10 Text: (Same as above)

T.| he
..| quick
~~' brown
fox jumped
over the
lazy dog.

Lines: 4 Columns: 10 Text: (Same as above)

T..| he
...| quick
...| brown
~~~' fox
jumped
over the
lazy dog.

Lines: 2 Columns: 80 Text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor.

L| orem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.
~' Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec
consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero
egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem
lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor.

Lines: 3 Columns: 80 Text: (Same as above)

L.| orem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.
..| Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec
~~' consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget
libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta
lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non
tortor.

Lines: 4 Columns: 80 Text: (Same as above)

L..| orem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam
...| lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra
...| nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam
~~~' eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim,
ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies
a non tortor.

This is code-golf and standard loopholes apply.

Yay, another [tag:typography] challenge! We need more of these.

What happens when a word is longer than a column width, ie The quick brown fox jumped over the unenthusiastic dog for any of the first three examples?

@MickyT Assume none of the words will be longer than the column width. That is, column width > longest word + drop capital height

What if the capital lines are greater than the line of text? Ie. L:4,C:100,T:'Stuff'

Also, can Lines = 1?

@TFeld You may assume those are both invalid inputs. Both numbers are strictly greater than one and every line will have at least one word.

Python 2, 202 bytes
def f(l,c,t):
 l-=1;s=['.'*l+'|']*l+['~'*l+"'"]
 s[0]=t[0]+s[0][1:];t=t[1:].split();j=0
 while t:
  w=t.pop(0)
  if len(s[j]+w)>=c:j+=1
  if j>=len(s):s.append(w)
  else:s[j]+=' '+w
 return '\n'.join(s)

Call as f(Lines, Columns, Text)
f(4,100,'Stuff') gives
S..| tuff
...|
...|
~~~'

C#, 244 bytes
string F(int d,int c,string t){var w=t.Substring(1).Split(' ');t=""+t[0];for(int i=0,x=c,y=0;i<w.Length;x+=w[i++].Length+1)t+=(1>(x=x+w[i].Length>c?0:x)?"\n"+(y++<d?(y<d?"| ":"' ").PadLeft(x=d+1,y<d?'.':'~'):""):" ")+w[i];return t.Remove(1,2);}

Indentation, new lines and comments for clarity:
string F(int d,int c,string t){
    var w=t.Substring(1).Split(' ');
    t=""+t[0];
    for(int i=0,x=c,y=0;i<w.Length;x+=w[i++].Length+1)
        t+=(1>(x=x+w[i].Length>c?0:x)?"\n"+(y++<d?(y<d?"| ":"' ").PadLeft(x=d+1,y<d?'.':'~'):""):" ")+w[i];
    return t.Remove(1,2);
}


text:
Tiny Lisp, tiny interpreter
Lisp programmers boast that Lisp is a powerful language which can be built up from a very small set of primitive operations. Let's put that idea into practice by golfing an interpreter for a dialect called tinylisp.
Language specification
In this specification, any condition whose result is described as "undefined" may do anything in your interpreter: crash, fail silently, produce random gobbldegook, or work as expected. A reference implementation in Python 3 is available here.
Syntax
Tokens in tinylisp are (, ), or any string of one or more printable ASCII characters except parentheses or space. (I.e. the following regex: [()]|[^() ]+.) Any token that consists entirely of digits is an integer literal. (Leading zeros are okay.) Any token that contains non-digits is a symbol, even numeric-looking examples like 123abc, 3.14, and -10. All whitespace (including, at a minimum, ASCII characters 32 and 10) is ignored, except insofar as it separates tokens.
A tinylisp program consists of a series of expressions. Each expression is either an integer, a symbol, or an s-expression (list). Lists consist of zero or more expressions wrapped in parentheses. No separator is used between items. Here are examples of expressions:
4
tinylisp!!
()
(c b a)
(q ((1 2)(3 4)))

Expressions that are not well-formed (in particular, that have unmatched parentheses) give undefined behavior. (The reference implementation auto-closes open parens and stops parsing on unmatched close parens.)
Data types
The data types of tinylisp are integers, symbols, and lists. Built-in functions and macros can also be considered a type, though their output format is undefined. A list can contain any number of values of any type and can be nested arbitrarily deeply. Integers must be supported at least from -2^31 to 2^31-1.
The empty list ()--also referred to as nil--and the integer 0 are the only values that are considered logically false; all other integers, nonempty lists, builtins, and all symbols are logically true.
Evaluation
Expressions in a program are evaluated in order and the results of each sent to stdout (more on output formatting later).

An integer literal evaluates to itself.
The empty list () evaluates to itself.
A list of one or more items evaluates its first item and treats it as a function or macro, calling it with the remaining items as arguments. If the item is not a function/macro, the behavior is undefined.
A symbol evaluates as a name, giving the value bound to that name in the current function. If the name is not defined in the current function, it evaluates to the value bound to it at global scope. If the name is not defined at current or global scope, the result is undefined (reference implementation gives an error message and returns nil).

Built-in functions and macros
There are seven built-in functions in tinylisp. A function evaluates each of its arguments before applying some operation to them and returning the result.

c - cons[truct list]. Takes two arguments, a value and a list, and returns a new list obtained by adding the value at the front of the list.
h - head (car, in Lisp terminology). Takes a list and returns the first item in it, or nil if given nil.
t - tail (cdr, in Lisp terminology). Takes a list and returns a new list containing all but the first item, or nil if given nil.
s - subtract. Takes two integers and returns the first minus the second.
l - less than. Takes two integers; returns 1 if the first is less than the second, 0 otherwise.
e - equal. Takes two values of the same type (both integers, both lists, or both symbols); returns 1 if the two are equal (or identical in every element), 0 otherwise. Testing builtins for equality is undefined (reference implementation works as expected).
v - eval. Takes one list, integer, or symbol, representing an expression, and evaluates it. E.g. doing (v (q (c a b))) is the same as doing (c a b); (v 1) gives 1.

"Value" here includes any list, integer, symbol, or builtin, unless otherwise specified. If a function is listed as taking specific types, passing it different types is undefined behavior, as is passing the wrong number of arguments (reference implementation generally crashes).
There are three built-in macros in tinylisp. A macro, unlike a function, does not evaluate its arguments before applying operations to them.

q - quote. Takes one expression and returns it unevaluated. E.g., evaluating (1 2 3) gives an error because it tries to call 1 as a function or macro, but (q (1 2 3)) returns the list (1 2 3). Evaluating a gives the value bound to the name a, but (q a) gives the name itself.
i - if. Takes three expressions: a condition, an iftrue expression, and an iffalse expression. Evaluates the condition first. If the result is falsy (0 or nil), evaluates and returns the iffalse expression. Otherwise, evaluates and returns the iftrue expression. Note that the expression that is not returned is never evaluated.
d - def. Takes a symbol and an expression. Evaluates the expression and binds it to the given symbol treated as a name at global scope, then returns the symbol. Trying to redefine a name should fail (silently, with a message, or by crashing; the reference implementation displays an error message). Note: it is not necessary to quote the name before passing it to d, though it is necessary to quote the expression if it's a list or symbol you don't want evaluated: e.g., (d x (q (1 2 3))).

Passing the wrong number of arguments to a macro is undefined behavior (reference implementation crashes). Passing something that's not a symbol as the first argument of d is undefined behavior (reference implementation doesn't give an error, but the value cannot be referenced subsequently).
User-defined functions and macros
Starting from these ten built-ins, the language can be extended by constructing new functions and macros. These have no dedicated data type; they are simply lists with a certain structure:

A function is a list of two items. The first is either a list of one or more parameter names, or a single name which will receive a list of any arguments passed to the function (thus allowing for variable-arity functions). The second is an expression which is the function body.
A macro is the same as a function, except that it contains nil before the parameter name(s), thus making it a three-item list. (Trying to call three-item lists that do not start with nil is undefined behavior; the reference implementation ignores the first argument and treats them as macros as well.)

For example, the following expression is a function that adds two integers:
(q               List must be quoted to prevent evaluation
 (
  (x y)          Parameter names
  (s x (s 0 y))  Expression (in infix, x - (0 - y))
 )
)

And a macro that takes any number of arguments and evaluates and returns the first one:
(q
 (
  ()
  args
  (v (h args))
 )
)

Functions and macros can be called directly, bound to names using d, and passed to other functions or macros.
Since function bodies are not executed at definition time, recursive functions are easily definable:
(d len
 (q (
  (list)
  (i list                      If list is nonempty
   (s 1 (s 0 (len (t list))))  1 - (0 - len(tail(list)))
   0                           else 0
  )
 ))
)

Note, though, that the above is not a good way to define a length function because it doesn't use...
Tail-call recursion
Tail-call recursion is an important concept in Lisp. It implements certain kinds of recursion as loops, thus keeping the call stack small. Your tinylisp interpreter must implement proper tail-call recursion!

If the return expression of a user-defined function or macro is a call to another user-defined function or macro, your interpreter must not use recursion to evaluate that call. Instead, it must replace the current function and arguments with the new function and arguments and loop until the chain of calls is resolved.
If the return expression of a user-defined function or macro is a call to i, do not immediately evaluate the branch that is selected. Instead, check whether it is a call to another user-defined function or macro. If so, swap out the function and arguments as above. This applies to arbitrarily deeply nested occurrences of i.

Tail recursion must work both for direct recursion (a function calls itself) and indirect recursion (function a calls function b which calls [etc] which calls function a).
A tail-recursive length function (with a helper function len*):
(d len*
 (q (
  (list accum)
  (i list
   (len*
    (t list)
    (s 1 (s 0 accum))
   )
   accum
  )
 ))
)
(d len
 (q (
  (list)
  (len* list 0)
 ))
)

This implementation works for arbitrarily large lists, limited only by the max integer size.
Scope
Function parameters are local variables (actually constants, since they can't be modified). They are in scope while the body of that call of that function is being executed, and out of scope during any deeper calls and after the function returns. They can "shadow" globally defined names, thereby making the global name temporarily unavailable. For example, the following code returns 5, not 41:
(d x 42)
(d f
 (q (
  (x)
  (s x 1)
 ))
)
(f 6)

However, the following code returns 41, because x at call level 1 is not accessible from call level 2:
(d x 42)
(d f
 (q (
  (x)
  (g 15)
 ))
)
(d g
 (q (
  (y)
  (s x 1)
 ))
)
(f 6)

The only names in scope at any given time are 1) the local names of the currently executing function, if any, and 2) global names.
Submission requirements
Input and output
Updated June 2022 to be more flexible
Your interpreter should input a tinylisp program in one of two ways:

directly, as a multiline string, or
indirectly, as the name of a file containing the tinylisp program.

It should evaluate each expression in the program one by one, outputting each result with a trailing newline.

Integers should be output in your implementation language's most natural representation. Negative integers can be output, with leading minus signs.
Symbols should be output as strings, with no surrounding quotes or escapes.
Lists should be output with all items space-separated and wrapped in parentheses. A space inside the parentheses is optional: (1 2 3) and ( 1 2 3 ) are both acceptable formats.
Outputting built-in functions and macros is undefined behavior. (The reference interpretation displays them as <built-in function>.)

All default input and output methods are acceptable. Your submission may be a full program or a function.
Other
The reference interpreter includes a REPL environment and the ability to load tinylisp modules from other files; these are provided for convenience and are not required for this challenge.
Test cases
The test cases are separated into several groups so that you can test simpler ones before working up to more-complex ones. However, they will also work just fine if you dump them all in one file together. Just don't forget to remove the headings and the expected output before running it.
If you have properly implemented tail-call recursion, the final (multi-part) test case will return without causing a stack overflow. The reference implementation computes it in about six seconds on my laptop.

"Any token that consists entirely of digits is an integer literal. (Leading zeros are okay.) Any token that contains non-digits is a symbol, even numeric-looking examples like 123abc, 3.14, and -10." seems to contradict "Integers must be supported at least from -2^31 to 2^31-1."

@msh210 Not really, because the former is talking about tokens whereas the latter is talking about values. Even though there's no direct way to enter -1, I can still generate the value -1 by doing (s 0 1).

The spec says it's undefined behavior to compare objects of different types. If I'm recursively comparing lists, and at some level have to compare two objects of different types, is that also undefined?

@feersum Correct. This means it's not strictly possible in tinylisp to write a function to compare two arbitrary lists (though the builtin e can tell you whether two lists are identical or not). Of course, if your submission is capable of handling this case gracefully, then so much the better.

Is the evaluation order of items in a list defined? The case I have in mind is that one of them defines a global variable, which the others then reference.

@feersum Good question. I'm going to say that's undefined. I'm pretty sure the reference implementation does LTR, but there's nothing in the test cases that would require one way or the other.

From your explanations, I guess that you want to have lexical binding of symbols. Maybe this should be made explicit.

@coredump After reading the pertinent Wikipedia article, I've concluded that the implementation is actually closer to dynamic, but with no scope nesting. Variables in function F are not available in function G if F calls G (as with dynamic scoping), but they are also not available in function H if H is a nested function defined inside F (as with lexical scoping)--see test case 5. So calling it "lexical" might be misleading.

To put it another way: because of the lack of scope nesting, an implementation could use either a dynamic or a lexical scoping strategy and come up with the same results. The only names in scope at any given time are 1) the local names of the currently executing function, if any, and 2) global names. Closures are not supported. (The reference implementation keeps a stack of name bindings corresponding to the call stack--a dynamic-style approach, which I think will be the easiest to implement.)

@Ell I brought this up in chat previously: http://chat.stackexchange.com/transcript/240?m=25126700#25126700

What are the valid types for the condition of i?

@feersum Anything. (See second paragraph of "Data types" section.)

Should v eval in the caller's scope or the global scope?

@feersum In the current local scope. It's just as if the code were being executed there directly.

Obligatory xkcd.

Can I assume a maximum name length?

@feersum Sure, I can live with that. How does 99 characters sound?

@Ell v does not have to be tail recursive. (It isn't tail recursive in the reference implementation, incidentally.) But it's really neat that your implementation does it that way!

The evaluation rule for a list should make explicit that the first item can be a symbol which is bound to a function, not just a function itself. For example: »A list of one or more items treats its first item as a function or macro (or a symbol which is bound to one) and calls it with the remaining items as arguments.«

To what should ((q ((#2) (s 6 #2))) 1) evaluate? As I see it, this takes (q ((#2) (s 6 #2))) as a function list, where q is the (unused) parameters name and ((#2) (s 6 #2)) the expression. And this tries to interpret (#2) as a function/macro, but it isn't (too few elements). Did I understand something wrong, or is there a mistake in your last example of In 5?

@PaŭloEbermann I think this edit will answer both of your points: "A list of one or more items evaluates its first item and treats it as a function or macro." To your first point, the symbol is evaluated to whatever that name is bound to (which should be a function/macro). To the second point, the list (q ((#2) (s 6 #2))) is first evaluated as code. That evaluation sends the list ((#2) (s 6 #2)) to the q macro, which returns it unevaluated as a literal list, and that list is then treated as a function. Does that help?

@DLosc yes, this helps, thank you. I will post my solution as soon as I solved the last quirks (not related to these issues).

Python 2, 685 675 660 657 646 642 640 bytes
import sys,re
E=[]
G=zip("chtsle",[eval("lambda x,y=0:"+f)for f
in"[x]+y (x+[E])[0] x[1:] x-y +(x<y) +(x==y)".split()])
def V(e,L=E):
 while 1:
    try:return e and int("0%s"%e)
    except:A=e[1:]
    if""<e:return dict(G+L).get(e,e)
    f=V(e[0],L)
    if""<f:
     if f in"iv":t=V(A[0],L);e=(e[~bool(t)],t)[f>"u"];continue
     if"e">f:G[:]+=(A[0],V(A[1],L)),
     return A[0]
    if[]>f or f[0]:A=[V(a,L)for a in A]
    if[]>f:return f(*A)
    P,e=f[-2:];L=([(P,A)],zip(P,A))[P<""]
F=lambda x:V<x<""and"(%s)"%" ".join(map(F,x))or"%s"%x
for t in re.sub("([()])"," \\1 ",sys.stdin.read()).split():
 if")"==t:t=E.pop()
 if"("==t:E+=[],
 elif E:E[-1]+=t,
 else:print F(V(t))

Reads input from STDIN and writes output to STDOUT.
Although not strictly required, the interpreter supports nullary functions and macros, and optimizes tail calls executed through v.
Explanation
Parsing
To parse the input, we first surround each occurence of ( and ) with spaces, and split the resulting string into words; this gives us the list of tokens.
We maintain an expression stack E, which is initially empty.
We scan the tokens, in order:

if we encounter a (, we push an empty list at the top of the expression stack;
if we encounter a ), we pop the value at the top of the expression stack, and append it to the list that was previously below it on the stack;
otherwise, we append the current token, as a string, to the list at the top of the expression stack (we keep integers as strings at this stage, and parse them during evaluation.)

If, when processsing an ordinary token, or after popping an expression from the stack due to ), the expression stack is empty, we're at a top-level expression, and we evaluate the value we'd otherwise have appended, using V(), and print its result, formatted appropriately using F().
Evaluation
We maintain the global scope, G, as a list of key/value pairs.
Initially, it contains only the builtin functions (but not the macros, and not v, which we treat as a macro), which are implemented as lambdas.
Evaluation happens inside V(), which takes the expression to evaluate, e, and the local scope, L, which is, too, a list of key/value pairs (when evaluating a top-level expression, the local scope is empty.)
The guts of V() live inside an infinite loop, which is how we perform tail-call optimization (TCO), as explained later.
We process e according to its type:

if it's the empty list, or a string convertible to an int, we return it immediately (possibly after conversion to int); otherwise,
if it's a string, we look it up in a dictionary constructed from the concatenation of the global and local scopes.
If we find an associated value, we return it; otherwise, e must be the name of a builtin macro (i.e. q, i, d or v), and we return it unchanged.
Otherwise, if e is not a string,
e is a (nonempty) list, i.e., a function call.
We evaluate the first element of the list, i.e., the function expression, by calling V() recursively (using the current local scope); we call the result f.
The rest of the list, A, is the list of arguments.
f can only be a string, in which case it's a builtin macro (or the function v), a lambda, in which case it's a builtin function, or a list, in which case it's a user-defined function or macro.
If f is a a string, i.e., a builtin macro, we handle it in-place.
If it's the macro i or v, we evaluate its first operand, and either select the second or third operand accordingly, in the case of i, or use the result of the first operand, in the case of v;
instead of evaluating the selected expression recursively, which would defeat TCO, we simply replace e with the said expression, and jump to the beginning of the loop.
If f is the macro d, we append a pair, whose first element is the first operand, and whose second element is the result of evaluating the second operand, to the global scope, G, and return the first operand.
Otherwise, f is the macro q, in which case we simply return its operand directly.
Othrtwise, if f is a lambda, or a list whose first element is not (), then it's a non-nullary function, not a macro, in which case we evaluate its arguments, i.e., the elements of A, and replace A with the result.
If f is a lambda, we call it, passing it the unpacked arguments in A, and return the result.
Otherwise, f is a list, i.e., a user-defined function or macro; its parameter list is the second-to-last element, and its body is the last element.
Like in the case of the macros i and v, in order to perform TCO, we don't evaluate the body recursively, but rather replace e with the body and continue to the next iteration.
Unlike i and v, however, we also replace the local scope, L, with the new local scope of the function.
If the parameter list, P, is, in fact, a list, the new local scope is constructed by zipping the parameter list, P, with the argument list, A;
otherwise, we're dealing with a variadic function, in which case the new local scope has only one element, the pair (P, A).

REPL
If you want to play with it, here's a REPL version of the interpreter.
It supports redefining symbols, and importing files through either the command line arguments, or the (import <filename>) macro.
To exit the interpreter, terminate the input (usually, Ctrl+D or Ctrl+Z).

try:import sys,re,readline
except:0
E=[];G=zip("chtsle",[eval("lambda x,y=0:"+f)for f
in"[x]+y (x+[E])[0] x[1:] x-y +(x<y) +(x==y)".split()])
def V(e,L=E):
 while 1:
    try:return e and int("0%s"%e)
    except:A=e[1:]
    if""<e:return dict(G+L).get(e,e)
    f=V(e[0],L)
    if""<f:
     if f in"iv":t=V(A[0],L);e=(e[~bool(t)],t)[f>"u"];continue
     if"e">f:G[:]+=(A[0],V(A[1],L)),
     elif"j">f:X(open(str(A[0])).read())
     return A[0]
    if[]>f or f[0]:A=[V(a,L)for a in A]
    if[]>f:return f(*A)
    P,e=f[-2:];L=([(P,A)],zip(P,A))[P<""]
F=lambda x:V<x<""and"(%s)"%" ".join(map(F,x))or"%s"%x
def X(s,v=0):
 for t in re.sub("([()])"," \\1 ",s).split():
    if")"==t:t=E.pop()
    if"("==t:E[:]+=[],
    elif E:E[-1]+=t,
    else:
     x=V(t)
     if v:print F(x)
for f in sys.argv[1:]:X("(g %s)"%f)
while 1:
 try:X(raw_input(">."[[]<E]*3+" "),1)
 except EOFError:break
 except KeyboardInterrupt:E=[];print
 except Exception as e:print"Error: "+e.message

And here's an example session, implementing merge sort:

>>> (d let d) (d if i) (d head h) (d tail t) (d prepend c) (d less l)
let
if
head
tail
prepend
less
>>>
>>> (let list (q (x... x...)))
list
>>> (let lambda (q (() (params body) (list params body))))
lambda
>>> (let def (q (() (name params body) (
...     v (list (q let) name (list (q lambda) params body))
... ))))
def
>>>
>>> (def else(body) body)
else
>>> (def or(x y) ( if x x y ))
or
>>> (def and(x y) ( if x y x ))
and
>>>
>>> (def front-half(L) ( front-half/impl L L ))
front-half
>>> (def front-half/impl(L M) (
...     if M (
...         prepend (head L)
...                 (front-half/impl (tail L) (tail (tail M)))
...     ) (else
...         ()
...     )
... ))
front-half/impl
>>>
>>> (def back-half(L) ( back-half/impl L L ))
back-half
>>> (def back-half/impl(L M) (
...     if M (
...         back-half/impl (tail L) (tail (tail M))
...     ) (else
...         L
...     )
... ))
back-half/impl
>>>
>>> (def merge(L M comp) (
...     if (and L M) (
...         if (comp (head M) (head L)) (
...             prepend (head M) (merge L (tail M) comp)
...         ) (else (
...             prepend (head L) (merge (tail L) M comp)
...         ))
...     ) (else (
...         or L M
...     ))
... ))
merge
>>>
>>> (def sort(L comp) (
...     if (and L (tail L)) (
...         merge (sort (front-half L) comp)
...               (sort (back-half L) comp)
...               comp
...     ) (else
...         L
...     )
... ))
sort
>>>
>>>
>>> (let my-list (list 4 7 2 5 9 1 6 10 8 3))
my-list
>>> my-list
(4 7 2 5 9 1 6 10 8 3)
>>> (sort my-list less)
(1 2 3 4 5 6 7 8 9 10)
>>> (sort my-list (lambda(x y) ( less y x )))
(10 9 8 7 6 5 4 3 2 1)

You can get something ever shorter using zlib :)
Compress your code converted in bytes, and replace it with :
import zlib;exec(zlib.decompress(your_code_compressed_in_bytes))

You could save two bytes by assigning A[0] to some one-char variable just after except block

@HannesKarppila That's right, but this would break nullary functions (since A is empty in this case), and I don't want to "regress".

C (GNU), 1095 bytes
Much of the action takes place in the giant v function. Instead of implementing tail recursion explicitly, v is structured so that many of the calls from v to v will be handled by gcc's tail recursion optimization. There is no garbage collection.
This makes heavy use of GCC extensions, so it could only be compiled with gcc (use the command gcc -w -Os tl.c). It also uses some scanf extensions which were not available on Windows, which I usually use. The prospect of writing the parser with standard scanf was so awful that I used a Linux VM to test the program instead. Parsing without scanf character classes probably would have added 100+ bytes.
#define O(...)({o*_=malloc(32);*_=(o){__VA_ARGS__};_;})
#define P printf
#define F(I,B)({for(I;x->c;x=x->l)B;})
#define Z return
typedef struct o{struct o*n,*l,*c;int i,t;}o;E(o a,o b){Z
a.n?!strcmp(a.n,b.n):a.c?b.c&&E(*a.c,*b.c)&E(*a.l,*b.l):!b.c&a.i==b.i;}p(o*x){x->t?P("%d ",x->i):x->n?P("%s ",x->n):F(P("("),p(x->c);P(")"));}o*x,G,N;*C(o*h,o*t){Z
O(c:h,l:t);}o*v(o*x,o*e){o*W(o*l,o*e){Z
l->c?C(v(l->c,e),W(l->l,e)):&N;}o*y,*a,*f;int t;Z
x->c?y=v(x->c,e),x=x->l,t=y->i,t?9/t?a=v(x->c,e),t>7?(t>8?a->c:a->l)?:a:t>6?v(a,e):t<6?x=v(x->l->c,e),t>4?C(a,x):O(t:1,i:t>3?E(*a,*x):t>2?a->i<x->i:a->i-x->i):v((a-&N&&!a->t|a->i?x:x->l)->l->c,e):(t&1&&d(x->c->n,v(x->l->c,e)),x->c):(y->l->l->l?y=y->l:(x=W(x,e)),a=y->c,v(y->l->c,a->n?O(n:a->n,c:x,l:&G):F(f=&G,(f=O(n:a->c->n,c:x->c,l:f),a=a->l);f))):x->n?e->n?strcmp(x->n,e->n)?v(x,e->l):e->c:e:x;}d(o*n,o*x){*v(O(n:""),&G)=(o){n:n,c:x,l:O()};}*R(h){char*z,*q;Z
scanf(" %m[^ \n()]",&q)>0?h=strtoul(q,&z,10),C(*z?O(n:q):O(t:1,i:h),R()):~getchar()&1?q=R(),C(q,R()):&N;}main(i){for(;++i<12;)d(strndup("slecivthqd"+i-2,1),O(i:i));F(x=R(),p(v(x->c,&G)));}

Semi-ungolfed
typedef struct o o;
struct o {
    char* n;
    o* l, //next in this list
     * c;
    int i,
        t;
} ;

#define O(...)({o*_=malloc(32);*_=(o){__VA_ARGS__};_;})

E(o a, o b) { //tests equality
    return
        a.n ? !strcmp(a.n,b.n) :
        a.t ? a.i==b.i :
        a.c ? b.c && E(*a.c,*b.c)&E(*a.l,*b.l) :
        !b.c
    ;
}

#define P printf

p(o*x){
    x->t?P("%d ",x->i):x->n?P("%s ",x->n):({for(P("(");x->c;x=x->l)p(x->c);P(")");});
}

o*_,G,N; //N = nil

o*C(o*h,o*t){return O(c:h,l:t);}

/*
        2 3 4 5 6 7 8 9 10 11
        s l e c i v t h d  q
    */

o* v(o* x, o* e) { //takes list, int, or name
    o*W(o* l, o* e) { //eval each item in list
        return l->c ? C(v(l->c ,e), W(l->l, e)) : &N;
    }

    o*y,*a,*f;int t;
    return x->c ? //nonempty list = function/macro call
        y = v(x->c,e), //evals to function/macro
        x = x->l,   //list position of first arg (if it exists)
        (t=y->t)?   //builtin no., if any
             t>9 ?
              t&1 ? x->c // 11 = q
                : //10 = d
                (d(x->c,v(x->l->c,e)),x->c)
           : (a = v(x->c,e), //eval'd first arg
             t)>7 ? // t/h
                (t > 8 ? a->c : a->l) ?: a
           : t>6 ? //v
                v(a,e)
           : (x = x->l, //position of 2nd arg in list
             t)>5 ? //i
                v( (a->n||a->l||a->i|a->t>1 ? x : x->l)->c, e)
           : (x = v(x->c,e), //evaluated 2nd arg
             t)>4 ? // c
                C(a,x)
           : O(t:1,i:
                t>3 ? E(*a,*x) :  //e
                t>2 ? a->i<x->i : //l
                      a->i-x->i   //s
              )
        :
        (
            y->l->l->l ? //whether this is macro
                y = y->l :
                (x = W(x,e)),  //eval args
            a = y->c,  //a = arg list
            //a = a->n ? x=C(x, &N), C(a, &N) : a, //transform variadic style to normal
            v(y->l->c,
               a->n ? //variadic
                O(n:a->n,c:x,l:&G)
              : ({
                   for(f=&G; a->c; a=a->l,x=x->l)
                      f=O(n:a->c->n, c: x->c, l:f);
                   f;
                })
            )
        )
    :
    x->n ? // name
        e->n ?
            strcmp(x->n,e->n) ?
                v(x,e->l)
            : e->c
        : e
     : x; //int or nil
}

d(o*n,o*x){
    * v(O(n:""),&G) =
        (o){n:n->n,c:x,l:O()};
}

;
o*R(){
    char*z,*q;int h;
return scanf(" %m[^ \n()]",&q)>0?
    h=strtoul(q,&z,10),
    C(*z ? O(n:q) : O(t:1,i:h), R())
: getchar()&1?&N:(q=R(),C(q,R()));
}
main(i) {

    for(;++i<12;) d(O(n:strndup("slecivthdq"+i-2,1)),O(t:i));

    o *q;
    for(q=R(); q->c; q=q->l) p(v(q->c,&G));

}

What is the usage of the compiled executable? Is it REPL? Does it take a filename as input?

@ckjbgames It reads a program from stdin.

Okay. I think you should edit your answer and note that.

Ceylon, 2422 bytes
(I think this is my longest golfed program yet.)
import ceylon.language{sh=shared,va=variable,fo=formal,O=Object}import ceylon.language.meta.model{F=Function}interface X{sh fo V v(S t);sh fo G g;}class G(va Map<S,V>m)satisfies X{v(S t)=>m[t]else nV;g=>this;sh S d(S s,V v){assert(!s in m);m=map{s->v,*m};return s;}}V nV=>nothing;class LC(G c,Map<S,V>m)satisfies X{g=>c;v(S t)=>m[t]else g.v(t);}alias C=>V|Co;interface Co{sh fo C st();}interface V{sh fo C l(X c,V[]a);sh default Boolean b=>0<1;sh fo C vO(X c);sh default V vF(X c){va C v=vO(c);while(is Co n=v){v=n.st();}assert(is V r=v);return r;}}class L(sh V*i)satisfies V{vO(X c)=>if(nonempty i)then i[0].vF(c).l(c,i.rest)else this;equals(O o)=>if(is L o)then i==o.i else 1<0;b=>!i.empty;string=>"(``" ".join(i)``)";hash=>i.hash;sh actual C l(X c,V[]p){value[h,ns,x]=i.size<3then[f,i[0],i[1]]else[m,i[1],i[2]];value n=if(is L ns)then[*ns.i.narrow<S>()]else ns;assert(is S|S[]n,is V x);V[]a=h(c,p);LC lC=if(is S n)then LC(c.g,map{n->L(*a)})else LC(c.g,map(zipEntries(n,a)));return object satisfies Co{st()=>x.vO(lC);};}}class S(String n)satisfies V{vO(X c)=>c.v(this);l(X c,V[]a)=>nV;equals(O o)=>if(is S o)then n==o.n else 1<0;hash=>n.hash;string=>n;}class I(sh Integer i)satisfies V{vO(X c)=>this;l(X c,V[]a)=>nV;equals(O o)=>if(is I o)then i==o.i else 1<0;hash=>i;b=>!i.zero;string=>i.string;}V[]f(X c,V[]a)=>[for(v in a)v.vF(c)];V[]m(X c,V[]a)=>a;L c(X c,V h,L t)=>L(h,*t.i);V h(X c,L l)=>l.i[0]else L();V t(X c,L l)=>L(*l.i.rest);I s(X c,I f,I s)=>I(f.i-s.i);I l(X c,I f,I s)=>I(f.i<s.i then 1else 0);I e(X c,V v1,V v2)=>I(v1==v2then 1else 0);C v(X c,V v)=>v.vO(c);V q(X c,V a)=>a;C i(X c,V d,V t,V f)=>d.vF(c).b then t.vO(c)else f.vO(c);S d(X c,S s,V x)=>c.g.d(s,x.vF(c));class B<A>(F<C,A>nat,V[](X,V[])h=f)satisfies V given A satisfies[X,V+]{vO(X c)=>nV;string=>nat.declaration.name;l(X c,V[]a)=>nat.apply(c,*h(c,a));}{<S->V>*}b=>{S("c")->B(`c`),S("h")->B(`h`),S("t")->B(`t`),S("s")->B(`s`),S("l")->B(`l`),S("e")->B(`e`),S("v")->B(`v`),S("q")->B(`q`,m),S("i")->B(`i`,m),S("d")->B(`d`,m)};[V*]p(String inp){value ts=inp.split(" \n()".contains,1<0,1<0);va[[V*]*]s=[];va[V*]l=[];for(t in ts){if(t in" \n"){}else if(t=="("){s=[l,*s];l=[];}else if(t==")"){l=[L(*l.reversed),*(s[0]else[])];s=s.rest;}else if(exists i=parseInteger(t),i>=0){l=[I(i),*l];}else{l=[S(t),*l];}}return l.reversed;}sh void run(){va value u="";while(exists l=process.readLine()){u=u+l+"\n";}V[]e=p(u);X c=G(map(b));for(v in e){print(v.vF(c));}}

I could have golfed some bytes more, as I used some two-letter identifiers in some places, but I've run out of somewhat meaningful single letters for those. Although even this way it doesn't look like Ceylon very much ...
This is an object-oriented implementation.
We have a value interface V with implementing classes L (list – just a wrapper around a Ceylon sequential of V), S (symbol – wrapper around a string), I (integer – wrapper around a Ceylon integer) and B (builtin function or macro, a wrapper around a Ceylon function).
I use the standard Ceylon equality notation by implementing the equals method (and also the hash attribute, which is really only needed for symbols), and also the standard string attribute for output.
We have a Boolean attribute b (which is true by default, overridden in I and L to return false for empty lists), and two methods l (call, i.e. use this object as a function) and vO (evaluate one step). Both return either a value or a Continuation object which allows then evaluation for one more step, and vF (evaluate fully) loops until the result is not a continuation anymore.
A context interface allows access to variables. There are two implementations, G for the global context (which allows adding variables using the d builtin) and LC for a local context, which is active when evaluating the expression of a user function (it falls back to the global context).
Symbols evaluation accesses the context, lists (if non empty) evaluate by first evaluating their first element and then calling its call method. Call is implemented just by lists and builtins – it first evaluates the argument (if a function, not if a macro) and then does the actual interesting stuff – for builtins just what is hardcoded, for lists it creates a new local context and returns a continuation with that.
For the builtins I used a trick similar to what I used in my Shift Interpreter, which allows me to define them with the argument types they need, but call them with a generic sequence using reflection (the types will be checked at call time). This avoids type conversion/assertion hassle inside the functions/macros, but needs top-level functions so I can get their meta-model Function objects.
The p (parse) function splits the string at spaces, newlines and parentheses, then loops over the tokens and builds lists using a stack and a running list.
The interpreter (in the run method, which is the entry point) then takes this list of expressions (which are just values), evaluates each of them, and prints the result.

Below is a version with comments and run through a formatter.
An earlier version before I started golfing (and still with some misunderstandings about list evaluation) is found at my Github repository, I'll put this one there soon (so make sure to look at the first version if you want the original).
//  Tiny Lisp, tiny interpreter
//
// An interpreter for a tiny subset of Lisp, from which most of the
// rest of the language can be bootstrapped.
//
// Question:   https://codegolf.stackexchange.com/q/62886/2338
// My answer:  https://codegolf.stackexchange.com/a/63352/2338
//
import ceylon.language {
    sh=shared,
    va=variable,
    fo=formal,
    O=Object
}
import ceylon.language.meta.model {
    F=Function
}

// context

interface X {
    sh fo V v(S t);
    sh fo G g;
}
// global (mutable) context, with the buildins
class G(va Map<S,V> m) satisfies X {
    // get entry throws error on undefined variables.
    v(S t) => m[t] else nV;
    g => this;
    sh S d(S s, V v) {
        // error when already defined
        assert (!s in m);
        // building a new map is cheaper (code-golf wise) than having a mutable one.
        m = map { s->v, *m };
        return s;
    }
}

// This is simply a shorter way of writing "this is not an allowed operation".
// It will throw an exception when trying to access it.
// nV stands for "no value".
V nV => nothing;

// local context
class LC(G c, Map<S,V> m) satisfies X {
    g => c;
    v(S t) => m[t] else g.v(t);
    // sh actual String string => "[local: ``m``, global: ``g``]";
}

// continuation or value
alias C => V|Co;

// continuation
interface Co {
    sh fo C st();
}

// value
interface V {
    // use this as a function and call with arguments.
    // will not work for all types of stuff.
    sh fo C l(X c, V[] a);
    // check the truthiness. Defaults to true, as
    // only lists and integers can be falsy.
    sh default Boolean b => 0 < 1;
    // evaluate once (return either a value or a continuation).
    // will not work for all kinds of expression.
    sh fo C vO(X c);
    /// evaluate fully
    sh default V vF(X c) {
        va C v = vO(c);
        while (is Co n = v) {
            v = n.st();
        }
        assert (is V r = v);
        return r;
    }
}
class L(sh V* i) satisfies V {

    vO(X c) => if (nonempty i) then i[0].vF(c).l(c, i.rest) else this;
    equals(O o) => if (is L o) then i == o.i else 1 < 0;
    b => !i.empty;
    string => "(``" ".join(i)``)";
    hash => i.hash;

    sh actual C l(X c, V[] p) {
        value [h, ns, x] =
                i.size < 3
                then [f, i[0], i[1]]
                else [m, i[1], i[2]];
        // parameter names – either a single symbol, or a list of symbols.
        // If it is a list, we filter it to throw out any non-symbols.
        // Should throw an error if there are any, but this is harder.
        value n = if (is L ns) then [*ns.i.narrow<S>()] else ns;
        assert (is S|S[] n, is V x);
        V[] a = h(c, p);

        // local context
        LC lC = if (is S n) then
            LC(c.g, map { n -> L(*a) })
        else
            LC(c.g, map(zipEntries(n, a)));
        // return a continuation instead of actually
        // calling it here, to allow stack unwinding.
        return object satisfies Co {
            st() => x.vO(lC);
        };
    }
}

// symbol
class S(String n) satisfies V {
    // evaluate: resolve
    vO(X c) => c.v(this);
    // call is not allowed
    l(X c, V[] a) => nV;
    // equal if name is equal
    equals(O o) => if (is S o) then n == o.n else 1 < 0;
    hash => n.hash;
    string => n;
}

// integer
class I(sh Integer i) satisfies V {

    vO(X c) => this;
    l(X c, V[] a) => nV;
    equals(O o) => if (is I o) then i == o.i else 1 < 0;
    hash => i;
    b => !i.zero;
    string => i.string;
}

// argument handlers for functions or macros
V[] f(X c, V[] a) => [for (v in a) v.vF(c)];
V[] m(X c, V[] a) => a;

// build-in functions
// construct
L c(X c, V h, L t) => L(h, *t.i);
// head
V h(X c, L l) => l.i[0] else L();
// tail
V t(X c, L l) => L(*l.i.rest);
// subtract
I s(X c, I f, I s) => I(f.i - s.i);
// lessThan
I l(X c, I f, I s) => I(f.i < s.i then 1 else 0);
// equal
I e(X c, V v1, V v2) => I(v1 == v2 then 1 else 0);
// eval (returns potentially a continuation)
C v(X c, V v) => v.vO(c);

// build-in macros
// quote
V q(X c, V a) => a;
// if (also returns potentially a continuation)
C i(X c, V d, V t, V f) => d.vF(c).b then t.vO(c) else f.vO(c);
// define symbol in global context
S d(X c, S s, V x) => c.g.d(s, x.vF(c));

// buildin function or macro, made from a native function and an argument handler
class B<A>(F<C,A> nat, V[](X, V[]) h = f)
        satisfies V
        given A satisfies [X, V+] {
    vO(X c) => nV;
    string => nat.declaration.name;
    // this "apply" is a hack which breaks type safety ...
    // but it will be checked at runtime.
    l(X c, V[] a) => nat.apply(c, *h(c, a));
}

// define buildins
{<S->V>*} b => {
    S("c") -> B(`c`),
    S("h") -> B(`h`),
    S("t") -> B(`t`),
    S("s") -> B(`s`),
    S("l") -> B(`l`),
    S("e") -> B(`e`),
    S("v") -> B(`v`),
    S("q") -> B(`q`, m),
    S("i") -> B(`i`, m),
    S("d") -> B(`d`, m)
};

// parses a string into a list of expressions.
[V*] p(String inp) {
    // split string into tokens (retain separators, don't group them –
    // whitespace and empty strings will be sorted out later in the loop)
    value ts = inp.split(" \n()".contains, 1 < 0, 1 < 0);
    // stack of not yet finished nested lists, outer most at bottom
    va [[V*]*] s = [];
    // current list, in reverse order (because appending at the start is shorter)
    va [V*] l = [];
    for (t in ts) {
        if (t in " \n") {
            // do nothing for empty tokens
        } else if (t == "(") {
            // push the current list onto the stack, open a new list.
            s = [l, *s];
            l = [];
        } else if (t == ")") {
            // build a lisp list from the current list,
            // pop the latest list from the stack, append the created lisp list.
            l = [L(*l.reversed), *(s[0] else [])];
            s = s.rest;
        } else if (exists i = parseInteger(t), i >= 0) {
            // append an integer to the current list.
            l = [I(i), *l];
        } else {
            // append a symbol to the current list.
            l = [S(t), *l];
        }
    }
    return l.reversed;
}

// Runs the interpreter.
// This handles input and output, calls the parser and evaluates the expressions.
sh void run() {
    va value u = "";
    while (exists l = process.readLine()) {
        u = u + l + "\n";
    }
    V[] e = p(u);
    // create global context
    X c = G(map(b));
    // iterate over the expressions, ...
    for (v in e) {
        // print("  '``v``' → ...");
        // ... evaluate each (fully) and print the result.
        print(v.vF(c));
    }
}

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/