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
704 views Asked by Parisa Zaeri At
1
There are 1 answers
Related Questions in MATRIX
- Setting diagonal of a matrix to zero
- CUDA matrix inversion
- Function to create matrix of zeros and ones, with a certain density of ones
- DirectX 9 With No SDK Installed - How To Translate a D3DMATRIX?
- Using the sympy module to compute the matrix multiplication involving symbols
- Rendering a visualisation of matrix using pygame
- I do not receive iOS push notifications from Element Matrix Notify
- Matrix reconstruction by SVD in tensorflow
- Why does the following code detect this matrix as a non-singular matrix?
- Bound for product of matrices
- iterating through raster bands to perform calculation
- How to make a heatmap and the matrix for it?
- MATLAB: Turn every element of complex matrix into another matrix
- Matrix calculated based on the previous value
- Matlab array of structure
Related Questions in MULTIDIMENSIONAL-ARRAY
- How could you print a specific String from an array with the values of an array from a double array on the same line, using iteration to print all?
- How to populate two dimensional array
- Dynamic Nested Multi-Dimensional Arrays in Rust
- Numpy array methods are faster than numpy functions?
- Multioutput regression using GPU
- Unexpected result when assigning and printing pointer value of two-dimensional array with its name
- Getting distances of points in 2D space in an array in Fortran using the concept of broadcasting (Python)
- Using Closing Stock Balance as Opening Stock in subsequent line item
- Data structure for a console menu in Node.js with nested options that can be navigated backwards
- Consolidate column values within each subset of a multidimensional array as comma separated values
- Short for creating an array of hashes in powershell malfunction?
- How can i find every instance of a repeating string in a list, and then concatenate it to the list element that precedes it in every instance?
- Hierarchically group 2d array data by two columns and concatenate third column values in each unique path
- Sum multiple items in 2D array based on condition (javascript)
- Matrix Multiplication in using 2D arrays
Related Questions in APL
- Dyalog Trying to understand a Floating Point rounding issue
- Is there a special meaning to underbar variables names in APL
- What is the Dyalog equivalent of the APL/360 I-beam 26?
- Is there a Dyalog equivalent to DFT function from APL/360 "1 PLOTFORMAT"?
- Merge Vectors In APL
- Best way to import and handle non-rectangular (ragged) data
- How do I render trains as trees in Dyalog APL using dyalogscript?
- How do you find the name of the current namespace
- Dyalog APL, how to have utilitiy functions available in workspace but not mixed in with other functions
- How do I exit GNU APL?
- Dyalog APL: What are the miracles? Trouble with + and range
- Dyalog APL: How to execute a function regardless of errors?
- Apply a list of functions on the same right operand
- Filter a list of list based on data
- Dyalog APL: How to filter an array like filter()
Related Questions in DYALOG
- Dyalog Trying to understand a Floating Point rounding issue
- Is there a special meaning to underbar variables names in APL
- What is the Dyalog equivalent of the APL/360 I-beam 26?
- Is there a Dyalog equivalent to DFT function from APL/360 "1 PLOTFORMAT"?
- Best way to import and handle non-rectangular (ragged) data
- Return a character string from a C function in a shared library (Dyalog APL)
- How do I render trains as trees in Dyalog APL using dyalogscript?
- How do you find the name of the current namespace
- Dyalog APL, how to have utilitiy functions available in workspace but not mixed in with other functions
- Dyalog APL: What are the miracles? Trouble with + and range
- Dyalog APL: How to execute a function regardless of errors?
- Apply a list of functions on the same right operand
- Filter a list of list based on data
- Dyalog APL: How to filter an array like filter()
- Styling GUI Objects in Dyalog APL
Related Questions in ARRAY-REPLACE
- PHP Merge two arrays by keeping higher value if keys are the same
- how to change value of an array based on value php
- How to replace value of array in javascript with another value of array?
- APL: array's element replacement and multiplication
- Postgres array_replace function not existing in version 11, 12
- replace all values in array that have "o" letter in php
- How to merge two multi dimensional arrays by key value in php?
- Merge/Replace associative rows from one array with the associative rows of another array
- How to replace elements in array with elements of another array
- Replace elements in an associative array using another associative 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?
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!