Let's say in APL language, I have a 2D array of shape 10x3. I cannot figure it out how to: replace all the occurrence of some specific numbers (e.g. 1, 2, 3, 4) in the entire array with 0, 10, 100, 1000 respectively. So I want to map 1 to 0, 2 to 10, 3 to 100 and 4 to 1000 in the entire array.
APL: array's element replacement and multiplication
646 views Asked by Parisa Zaeri At
1
There are 1 answers
Related Questions in MATRIX
- No responses from google places text search api
- compare python requests with curl
- file_get_contents not working on my server but works fine anywhere else?
- Converting curl command to iOS
- cURL PHP code redirect after success
- curl command cannot get contents from api.github, but the network is fine
- PHP cURL Request for Web Service Returning Error
- How to convert CURL command to Swift
- curl command don't work in some cases
- Silence output curl_setopt_array
Related Questions in MULTIDIMENSIONAL-ARRAY
- No responses from google places text search api
- compare python requests with curl
- file_get_contents not working on my server but works fine anywhere else?
- Converting curl command to iOS
- cURL PHP code redirect after success
- curl command cannot get contents from api.github, but the network is fine
- PHP cURL Request for Web Service Returning Error
- How to convert CURL command to Swift
- curl command don't work in some cases
- Silence output curl_setopt_array
Related Questions in APL
- No responses from google places text search api
- compare python requests with curl
- file_get_contents not working on my server but works fine anywhere else?
- Converting curl command to iOS
- cURL PHP code redirect after success
- curl command cannot get contents from api.github, but the network is fine
- PHP cURL Request for Web Service Returning Error
- How to convert CURL command to Swift
- curl command don't work in some cases
- Silence output curl_setopt_array
Related Questions in DYALOG
- No responses from google places text search api
- compare python requests with curl
- file_get_contents not working on my server but works fine anywhere else?
- Converting curl command to iOS
- cURL PHP code redirect after success
- curl command cannot get contents from api.github, but the network is fine
- PHP cURL Request for Web Service Returning Error
- How to convert CURL command to Swift
- curl command don't work in some cases
- Silence output curl_setopt_array
Related Questions in ARRAY-REPLACE
- No responses from google places text search api
- compare python requests with curl
- file_get_contents not working on my server but works fine anywhere else?
- Converting curl command to iOS
- cURL PHP code redirect after success
- curl command cannot get contents from api.github, but the network is fine
- PHP cURL Request for Web Service Returning Error
- How to convert CURL command to Swift
- curl command don't work in some cases
- Silence output curl_setopt_array
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
I'll be using this example data:
Let's define a helper function to identify occurrences of elements that need to be mapped, namely those that are members of our list of specific numbers:
Next, we define a mapping function that looks up the index of each element in the set of specific numbers, and uses those indices to index into the replacements:
Now we can apply the mapping function at the occurrences:
We can define the whole thing as a single replacement function:
Or even go directly for the full definition without the helper functions:
The resulting definition will be the same: Try it online!
We can even define a general-purpose replacement operator: Try it online!
This operator definition can be found in APLcart with a query like search and replace elements.
Consider using a mathematical relationship between the specific values and the replacement values, rather than doing a lookup:
Now we can write: Try it online!