Chhwe (chhwe) wrote,
Chhwe
chhwe

  • Music:
/* atomize a string */
atomize:
say atomyze('2**3*4/3*4/(wer+er)**3*(4/456*23)')
exit
atomyze:
lbr = '('
rbr = ')'
plus = '+'
minus = '-'
powerS = '^t'
power = '**'
star = '*'
slash = '/'
atoms = arg(1)
makeatom(lbr)
makeatom(rbr)
makeatom(plus)
makeatom(minus)
makeatom(power)
atoms = translate(atoms,powerS,power)
makeatom(star)
makeatom(powerS)
atoms = translate(atoms,power,powerS)
makeatom(slash)
return atoms
Makeatom: Procedure Expose Atoms
sta = arg(1)
i = 0
do forever
   stai = index(atoms,sta,i+1)
   if stai = 0 then
      leave
   atoms=delstr(atoms,stai,length(sta))
   atoms=insert(' 'sta' ',atoms,stai-1)
   i = stai+2
end
return ''
Tags: prograsm
Subscribe

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments