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
702 Views Asked by Parisa Zaeri At
1
There are 1 best solutions below
Related Questions in MATRIX
- Initialize matrix
- Delete a column and a row in a square matrix in C
- multiply each columns of a matrix by a vector
- How can I extract the bounds of a bitmap in a canvas from the values in the transformation matrix?
- Find saddle points in Matlab
- Adding appending numpy arrays
- Python: Array subtract Matrix - TypeError: unsupported operand type(s) for -: 'int' and 'list'
- List of coordinates to matrix of distances
- Is there a way to make array entries complex variables in NumPy?
- Determining regression coefficients for data - MATLAB
- Turning matrix into list of integers as a spiral of given matrix
- Summing multiple columns to equal -1,0,1
- How do I get (LaTeX math) typeset matrix with borders in HTML output from *.Rmd?
- MATLAB Creating a symbolic function with matrix elements
- How to multiply 3 matrices using shared memory in Python?
Related Questions in MULTIDIMENSIONAL-ARRAY
- How to sort a multi-dimensional array by the second array in descending order?
- C programming: Create and write 2D array of files as function
- Working with multiple array in PHP
- PHP multidimensional array, average of duplicate values
- Multiple parameters in a Dictionary
- navigate through multidimensional PHP array by relative path
- How to double values in 2d array? C++
- Multidimensional Array view defined line
- .NET Array with Multiple Data Types
- Multidimensional Array modify values
- Rearrange multidimensional array from other array
- Callback set_message not working with multidimensional array post
- Javascript push multidimensional array only checked checkboxes
- Program crash while trying to print a bidimensional array
- How to extract all 2nd level values (leaf nodes) from a 2-dimensional array and join with commas?
Related Questions in APL
- How do I implement accumulation in APL?
- Dyalog APL - Disabling APL symbol input
- How come +.x in APL works for both matrices and vectors?
- Can GNU APL output be sent to a command line plotting program (e.g., gnuplot)?
- APL language compiler to IL
- APL: array's element replacement and multiplication
- How would I go about counting the amount of each alphanumerical in an array? (APL)
- How to manipulate multiple nested arrays in Dyalog APL?
- 3+ dimensional truth table in APL
- Dyalog APL, sort rows in a matrix
- How do I make sleep in Dyalog APL?
- Dyalog APL: convert JSON to a pure array
- Dyalog APL: what is the problem with loops?
- Dyalog APL: Check if a field exists in JSON?
- How can I read one byte from stdin in Dyalog APL?
Related Questions in DYALOG
- How do I implement accumulation in APL?
- Dyalog APL - Disabling APL symbol input
- APL: array's element replacement and multiplication
- How to manipulate multiple nested arrays in Dyalog APL?
- Dyalog APL, sort rows in a matrix
- How do I make sleep in Dyalog APL?
- Dyalog APL: convert JSON to a pure array
- Dyalog APL: what is the problem with loops?
- Dyalog APL: Check if a field exists in JSON?
- Styling GUI Objects in Dyalog APL
- How can I read one byte from stdin in Dyalog APL?
- Dyalog APL: How to filter an array like filter()
- Filter a list of list based on data
- Dyalog APL: How to execute a function regardless of errors?
- Apply a list of functions on the same right operand
Related Questions in ARRAY-REPLACE
- APL: array's element replacement and multiplication
- How to replace value of array in javascript with another value of array?
- Postgres array_replace function not existing in version 11, 12
- Merge/Replace associative rows from one array with the associative rows of another array
- replace all values in array that have "o" letter in php
- How to replace elements in array with elements of another array
- Replace elements in an associative array using another associative array
- how to change value of an array based on value php
- PHP Merge two arrays by keeping higher value if keys are the same
- How to merge two multi dimensional arrays by key value in php?
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)
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?
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!