* title snobol test program #8 -- bridge dealer trace('ran.var') trace('random','function') data('card(num,next)') * output('title',6,) output('dealer',6,) output('skip',6,) * define('insert(list,card)temp') :(insertend) * insert $list = ident($list) card(num(card),null) :s(return) $list = gt(num(card),num($list)) card(num(card),$list) . :s(return) temp = $list ins1 ident(next(temp)) :s(ins2) next(temp) = gt(num(card),num(next(temp))) . card(num(card),next(temp)) :s(return) temp = next(temp) :(ins1) ins2 next(temp) = card(num(card),null) :(return) insertend * * define('line(str1,col1,str2,col2)bl1,bl2') :(lineend) * line bl len(col1 - 1) . bl1 ident(str2) :s(line1) bl len(col2 - (col1 + size(str1))) . bl2 line1 line = bl1 str1 bl2 str2 :(return) lineend * * define('nth(list,num)temp') :(nthend) * nth nth = eq(num,0) $list :f(nth1) $list = next($list) :(return) nth1 temp = $list nth2 num = num - 1 nth = eq(num,0) next(temp) :s(nth3) temp = next(temp) :(nth2) nth3 next(temp) = next(next(temp)) :(return) nthend * * define('random(n)') :(randomend) random ran.var = ran.var * 1061 + 3251 ran.var arb rpos(5) = random = (ran.var * n) / 100000 :(return) randomend * * define('suitl(hand,suit)') :(suitlend) * suitl suitl = suit ' ' suitl1 gt(num($hand),$suit) :f(return) suitl = suitl $(num($hand) - $suit) $hand = differ(next($hand)) next($hand) :s(suitl1)f(return) suitlend -eject * * constants * bl = ' ' . ' ' s = 39 h = 26 d = 13 c = 0 $1 = 2 $2 = 3 $3 = 4 $4 = 5 $5 = 6 $6 = 7 $7 = 8 $8 = 9 $9 = 10 $10 = 'J' $11 = 'Q' $12 = 'K' $13 = 'A' dealseq = 'north,east,south,west,north,' ran.var = 157 dealmax = 3 nthdeal = deal = 'west' newdeal nthdeal = lt(nthdeal,dealmax) nthdeal + 1 :f(end) n = 1 north = east = south = west = deck = dloop deck = card(n,deck) n = lt(n,52) n + 1 :s(dloop) dealseq deal ',' break(',') . deal :f(err) hand = deal n = 52 nloop dealseq hand ',' break(',') . hand :f(err) insert(hand,nth('deck',random(n))) n = gt(n,1) n - 1 :s(nloop) -eject * * output of hand * title = 'Deal number: ' nthdeal dealer = 'Dealer is: ' deal skip = ' ' output = line('north',40) output = output = line(suitl('north','s'),40) output = line(suitl('north','h'),40) output = line(suitl('north','d'),40) output = line(suitl('north','c'),40) skip = ' ' output = line('west',20,'east',60) output = output = line(suitl('west','s'),20, . suitl('east','s'),60) output = line(suitl('west','h'),20, . suitl('east','h'),60) output = line(suitl('west','d'),20, . suitl('east','d'),60) output = line(suitl('west','c'),20, . suitl('east','c'),60) skip = ' ' output = line('south',40) output = output = line(suitl('south','s'),40) output = line(suitl('south','h'),40) output = line(suitl('south','d'),40) output = line(suitl('south','c'),40) . :(newdeal) end