I wanted to use Execute to convert numeric characters to numbers.
⍎¨'12 4' ' ' '4566'
Since the third item is a blank, the whole statement returns nothing. I wonder if this is according to the specifications because the two other items can be executed and would return values. Should not be that the statement should return a two element vector?
Kind regards,
Florian
Question on Execute
- Adam|Dyalog
- Posts: 143
- Joined: Thu Jun 25, 2015 1:13 pm
Re: Question on Execute
By definition, f¨Y must give an array of the same shape as Y, so if Y has 3 elements, as in your example, the result must too. But since one of the applications of ⍎ returns nothing, then ⍎¨ cannot return anything either.
You could work around this by appending ',⍬' to each vector before execution, which also ensures that each returned element is a vector (4566 would be a scalar otherwise):
However, using ⍎ to convert text to numbers is in general unsafe and unreliable. The industrial solution is to use ⎕VFI:
You could work around this by appending ',⍬' to each vector before execution, which also ensures that each returned element is a vector (4566 would be a scalar otherwise):
⍎¨'12 4' ' ' '4566',¨⊂',⍬'
┌────┬┬────┐
│12 4││4566│
└────┴┴────┘
However, using ⍎ to convert text to numbers is in general unsafe and unreliable. The industrial solution is to use ⎕VFI:
2⊃∘⎕VFI¨'12 4' ' ' '4566'
┌────┬┬────┐
│12 4││4566│
└────┴┴────┘
Re: Question on Execute
Hi Adam,
Thanks for the explanations and suggestion. I use ⎕VFI now instead of execute.
Kind regards,
Florian
Thanks for the explanations and suggestion. I use ⎕VFI now instead of execute.
Kind regards,
Florian