Change array inside DFNS
3 posts
• Page 1 of 1
Change array inside DFNS
Dear All,
i need to verify char in text file.
Actually, i follow this way :
but if LF, FF or RL character is inside, a simple display is alterate
i replace them by a blank space.
i play with more array, and i need to clarify code.
i would like to convert in dynamic function.
i try
and i receive a syntax error.
Where i am wrong ?
Not only, i try to sort array in the same way
Explanations are welcome !
have a good day
Yves
i need to verify char in text file.
Actually, i follow this way :
content ← ⎕nget filename
tab ← { (⎕ucs ⍺) , ⍺ , ⍴⍵ } ⌸ (⊃ content)
but if LF, FF or RL character is inside, a simple display is alterate
┌→────────┐
↓ 10 │
│ 12 │
│ 38 & 47│
│ 35 # 47│
│ 50 2 59│
│ 51 3 59│
...
i replace them by a blank space.
tab[ ⍸ (⎕ucs 10) = tab ] ← ' '
i play with more array, and i need to clarify code.
i would like to convert in dynamic function.
i try
changeLF ← { ⍵[ ( ⍸ (⎕ucs 10) = ⍵ ) ] ← ' ' }
changeLF tab
and i receive a syntax error.
Where i am wrong ?
Not only, i try to sort array in the same way
sortbyQty ← { ⍵[ ⍋⍵[;3] ; ] }and it works.
sortbyQty tab
Explanations are welcome !
have a good day
Yves
- Yves
- Posts: 39
- Joined: Mon Nov 30, 2015 11:33 am
Re: Change array inside DFNS
Hi Yves
In changeLF you are attempting to assign to ⍵ (or more precisely, attempting to apply selective assignment to ⍵). That is not supported in Dyalog APL.
Assigning to ⍺ has special meaning; it allows you to specify a default left argument to a dfn.
In SortByQty you are not attempting to assign to ⍵, so that will work.
You could alter your code to read something like:
In 16.0 onwards you can use the At operator:
or better still
In changeLF you are attempting to assign to ⍵ (or more precisely, attempting to apply selective assignment to ⍵). That is not supported in Dyalog APL.
Assigning to ⍺ has special meaning; it allows you to specify a default left argument to a dfn.
In SortByQty you are not attempting to assign to ⍵, so that will work.
You could alter your code to read something like:
changeLF ← { tmp←⍵ ⋄ tmp[ ( ⍸ (⎕ucs 97) = w ) ] ← ' ' ⋄ tmp}
In 16.0 onwards you can use the At operator:
changeLF←{' '@{(⎕ucs 10)=⍵}⍵}
or better still
changeLF←{' '@((⎕ucs 10)=⊢)⍵}
-
AndyS|Dyalog - Posts: 257
- Joined: Tue May 12, 2009 6:06 pm
Re: Change array inside DFNS
Hi Andy,
Thank you for your time.
i am not sure to well understand usage of ⊢, but it is wonderful solution.
finally, DFNS is only to transform something like
Yves
Thank you for your time.
i am not sure to well understand usage of ⊢, but it is wonderful solution.
finally, DFNS is only to transform something like
tab ← changeLF tab
Yves
- Yves
- Posts: 39
- Joined: Mon Nov 30, 2015 11:33 am
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group