WRT translating strings, the new []R operator makes changing strings a trivial thing:
1 ... '-' was replaced with '¯'
2 ... a currency symbol was found and ignored
3 ... ',' was interpreted as a "." decimal-marker ( European versus American )
you can do
Code: Select all
from←'-' '[$£¤€¥]' ','
to←'¯' '' '.'
]disp ⎕VFI from ⎕r to ⊢ '3.3 -321 $32,45 -654.32¥'
┌→──────┬──────────────────────┐
│1 1 1 1│3.3 ¯321 32.45 ¯654.32│
└~─────→┴~────────────────────→┘
and even more complex expressions like single spaced numbers (e.g. 12 345,67),
numbers surrounded by parentheses to denote negative numbers (e.g. (32.56) )
and multiple character currencies (e.g. 123.45DK):
Code: Select all
from←'[-(]' '([$£¤€¥]|DK|\))' ',' '(\d) (\d)'
to←'¯' '' '.' '\1\2'
]disp ⎕VFI from ⎕r to ⊢ 'DK123 456 789,50 -65 124.32¥ (12 345 678.90)€'
┌→────┬─────────────────────────────────┐
│1 1 1│123456789.5 ¯65124.32 ¯12345678.9│
└~───→┴~───────────────────────────────→┘
The possibilities are endless.