As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [lookup]

A lookup (table) is an array that replaces run-time computation with a simpler array indexing operation. The savings in terms of processing time can be significant, since retrieving a value from memory is often faster than undergoing an 'expensive' computation or input/output operation. Over time the definition has become less strict, any kind of searching with a key value can be considered a lookup.

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

Grouping and summing by condition from three mongodb collections

I have three mongodb collections. I would like to group the collections by date, month and year, then sum by condition in order to display totals from the three collections in one table. However, i ...
user20183888's user avatar
1 vote
1 answer
115 views

Optimize the FFT calculation in C++ without creating even/odd arrays

Here is my code: ...
Yalçın Cenik's user avatar
1 vote
3 answers
862 views

Any bettter way to achieve this lookup table?

What I need: I need a lookup table. Once the keywords are all found, then the value of the std::unordered_map is returned.And I don't care about the sequence of the ...
John's user avatar
  • 29
0 votes
1 answer
64 views

importing excel data by matching and performing lookups

This code imports data from a separate sheet and matches it based on Column E's data, it does this for every cell then offsets to the next one (622*6) times. If there are any substitutions for vlookup ...
Bubbybristor's user avatar
1 vote
0 answers
223 views

Get & change file names from folder

This was originally posted as a Stack Overflow answer. Objective Import all filenames from a folder & change the filename using a mapping table. Challenge As described in the original posting, ...
JasonC's user avatar
  • 11
10 votes
5 answers
3k views

Sine function calculated via look-up table and linear interpolation

I have been attempting to implement a function calculating values of the sine function. I know that there are several similar threads regarding this topic but my goal was to try to implement such ...
L3sek's user avatar
  • 385
6 votes
1 answer
344 views

Rust Book: The Twelve Days of Christmas

In order to learn Rust I'm going through The Rust Book and did the implemented a program for the following exercise: Print the lyrics to the Christmas carol “The Twelve Days of Christmas,” taking ...
muffin's user avatar
  • 63
3 votes
3 answers
239 views

Word frequencies from large body of scraped text

I have a file with word frequency logs from a very messy corpus of scraped Polish text that I am trying to clean to get accurate word frequencies. Since this is a big text file, I divided it into ...
Des Grieux's user avatar
6 votes
2 answers
50k views

Lookup closest value in Pandas DataFrame

I have a DataFrame that contains the data shown below: ...
wigging's user avatar
  • 265
4 votes
1 answer
85 views

Naming initialization functions in a lookup table based implementation of integer logarithms

Background (Feel free to skip; the help center just recommended adding background information :) A few days ago, I was looking at some code which happened to use a flat array to store a complete ...
Aleksi Torhamo's user avatar
4 votes
3 answers
5k views

Lookup table with fixed array

I implemented the following excercise: Implement a lookup table with operations such as find(struct table*, const char*), ...
Sandro4912's user avatar
  • 3,026
7 votes
4 answers
4k views

Converting a query result into an key=>value pairs for a lookup table

My app has a number of lookup tables stored in a MySQL database that are used for various purposes such as a select element. Unfortunately, the query results aren'...
pbarney's user avatar
  • 175
2 votes
1 answer
536 views

Typescript: Recursion file-system lookup

Previously I asked a question to find the best practice of recursively running a function to retrieve all import/export statements of files in NodeJs here. After some discussion I'm not satisfied yet,...
PRAISER's user avatar
  • 151
4 votes
2 answers
76 views

Lookups in list in C

I read about lookups in lists and I think that is what I did. I would like to compare it to a skip list, a binary search or a B+ tree. ...
Niklas Rosencrantz's user avatar
3 votes
0 answers
128 views

FizzBuzz - A quartet of solutions

Since the FizzBuzz challenge is about developing ideas, I've added a third test case for which I chose divisibility by 7 and its accompanying tag "Go". This tag was purposely given a length other ...
Sep Roland's user avatar
  • 4,278
2 votes
2 answers
70 views

Comparison of lookup methods

Background (these are the bits technically not for review, but feel free to point out any minor points) An Entity class can be identified by a name and at least ...
h.j.k.'s user avatar
  • 19.2k
6 votes
2 answers
2k views

Binary search a 2D array for multiple matching criteria fields

Here is what I came up with for a binary search of an array. It allows for searching one or many columns to match. It assumes that array being searched is sorted with the same sort priorities as the ...
Kevin Conner's user avatar
2 votes
1 answer
85 views

Optimize program to test for divisibility of numbers 3.0

This is a follow up on my previous question. JS1's answer suggested that I should use a precomputed table containing all permutations of the lowest valid number for each number between 1 and MAX. It ...
Linus's user avatar
  • 917
4 votes
1 answer
142 views

Look up parameters based on a numpy array of input values

Aim: Write a function that looks up empirical parameters A, B and C for a solar radiation ...
Fred S's user avatar
  • 143
3 votes
1 answer
2k views

Python lookup table

I'm trying to design a protocol for sending/receiving serial data. The basic plan is to allow for text data to be entered in the command prompt, translate that to a hex string and send it out over ...
user3817250's user avatar
3 votes
1 answer
26k views

Node.js JSON searching & updating

I'm working on a web-based on/off controller for multiple switches. I'm looking for a good way to manage the current state of a switch and updating the current state on change. So far I've got a <...
rwxes's user avatar
  • 33
6 votes
2 answers
2k views

How to speed up interval lookup for a piecewise defined function?

At the innermost loop of my software is a lookup of a function value from a piecewise defined function with interpolation between the sample points. Illustration: ...
user avatar
5 votes
2 answers
467 views

Conjugation tables for French

I'm in the process of structuring a model for conjugation tables for French. There are noun inflections, adverb inflections, and 19 verb conjugations. I'm trying to model the data so that every piece ...
Chris Cirefice's user avatar
35 votes
3 answers
16k views

Multiple indexes over an in memory collection for faster search

I have a big in-memory collection of following simplified class: ...
Atashbahar's user avatar
11 votes
1 answer
1k views

Partitioned Multikey Map

Below is the code for what I've called a partitioned_multitype_map. This has two major facets: Allowing a lookup based on keys of multiple lengths and of multiple ...
Yuushi's user avatar
  • 11k
5 votes
1 answer
5k views

Project Euler Problem 12 - Highly Divisible Triangular Number - Python Solution Optimization

Project Euler Problem 12 asks (paraphrased): Considering triangular numbers Tn = 1 + 2 + 3 + … + n, what is the first Tn with over 500 divisors? (For example, T7 = 28 has six divisors: 1, 2, 4, 7, ...
rcbevans's user avatar
  • 153
6 votes
1 answer
1k views

Critique of Cardinal Direction Enum

I'm working on a simple game in which I need to track the cardinal direction of an object. I experimented with using the enum's ordinal value, as well as using switches for the rotation, but both ...
weare138's user avatar
  • 541
5 votes
1 answer
615 views

Optimize text to ascii lookup map and scalability

Is there a more optimal way of retrieving the character for the letter? I would assume that I would just replace my Entry set loop with another map, but I do not want to bloat the code, because it ...
Mr. Polywhirl's user avatar
1 vote
1 answer
1k views

Whitelist input data for a lookup by name

I'm whitelisting the input data to an LDAP/AD search on 'sn' (=surname). The purpose is to stop penetration attacks through the app and into the LDAP servers (i.e. no brackets, please). ...
Boggin's user avatar
  • 198
7 votes
5 answers
829 views

Writing image pixel data to printer code

I've been trying to take image pixel data and write it out into printer code and my results are rather slow. Here is a simplified version of what I have so far (image is a PIL Image object of 1200 x ...
Octopus's user avatar
  • 339
4 votes
2 answers
242 views

Algorithm (and tests) to parse lists of unsigned 32-bit ints from strings in C

What? I have an algorithm that parses comma separated lists of unsigned 32-bit ints from strings. Here is an example of what a list could look like: ...
rzetterberg's user avatar
3 votes
2 answers
710 views

Returning a value based on a lookup

I am trying to return a value (a.tnAddress) from a custom class based on a lookup (foreach loop). Depending on the type of ...
user2437909's user avatar
5 votes
1 answer
11k views

Multiple criterias in a VLOOKUP in Excel VBA

I have made the following custom defined function in Excel. It works somehow like VLOOKUP(), but it takes two criteria. I think the code is a bit of a mess. Does ...
Jamgreen's user avatar
  • 153
8 votes
1 answer
2k views

Python property() implementation that caches getter while still allowing a setter

For a session implementation I needed a property that caches its getter (since it involves a database lookup) but still allows modifications (e.g. assigning a new user and storing that user's id in ...
ThiefMaster's user avatar
6 votes
1 answer
3k views

Mapping arrays to ranges in Ruby

I have a simple Rails app, which is used to run some clinical surveys. Participants answer sets of questions (multiple-choice, valued 1-5), and, within each set, the answers are summed up and the ...
Flambino's user avatar
  • 32.9k
11 votes
2 answers
99k views

JSON lookup by key

I always did my lookup in JSON collection like that: ...
Tommy B.'s user avatar
  • 246
3 votes
1 answer
544 views

JavaScript object to JSON

Since I didn't find a way to properly transform JavaScript object to JSON with PHP, I wrote a snippet. Lets assume the following excerpt from Google Fonts JavaScript API: ...
tomsseisums's user avatar
3 votes
1 answer
2k views

Tuple/Lookup conundrum

I have a list of plans and a list of contacts, and I have to check whether contact.ProviderId matches plan.ProviderId. If they ...
mitomed's user avatar
  • 539
2 votes
1 answer
4k views

Standard library-like linear interpolation table

I'm looking for a general review of a generalized linear interpolation table. Design decisions, anything that's missing, anything that could be clearer or simplified, any style considerations. Keep in ...
Yuushi's user avatar
  • 11k
1 vote
2 answers
495 views

Readability concerns with literal dictionary lookup vs if-else

I'm having concerns about the readability of this piece of code: ...
fortran's user avatar
  • 137
3 votes
1 answer
3k views

Dictionary tree optimization

I was wondering if anyone could give me a little bit of help with optimizing a tree-structure in C++. I'm currently developing a dictionary program for a school project but want to take it a bit ...
icdae's user avatar
  • 151
3 votes
1 answer
523 views

How can I make my A* algorithm faster?

This is a slightly specialised A* algorithm, basically it allows you to search to and from disabled nodes. It's for a game and we the entities spawn in houses and go into them. The rest of the search ...
Dollarslice's user avatar
2 votes
1 answer
120 views

Longest-match lookup via nested dicts

I have the following datastructure to perform a longest-match lookup via nested dicts. For example. cs['a b c d'] with a and <...
ThiefMaster's user avatar
10 votes
1 answer
3k views

Implementations of prefix lookup tables

I've got a fairly performance sensitive need for fast prefix lookup, and I've built two different implementations trying to optimize for my use case. The first is built off a Trie implementation, and ...
dimo414's user avatar
  • 377
5 votes
1 answer
396 views

First steps with amd64 assembly

I try to learn amd64 assembler. This is the first thing I tried. This piece of assembly should replicate the functionality of the following piece of C code, which turns a binary sha-256 hash into a ...
FUZxxl's user avatar
  • 641
3 votes
1 answer
193 views

Word lookup code optimization

I have a Java class which accepts some data and reads it in as a raster of characters x by y. The class is used then to look for occurrences of a certain word in any direction of the raster and store ...
jb10210's user avatar
  • 133
23 votes
1 answer
5k views

Create a re-usable class to get different values from enum attribute decorations

I'm wanting to create a Reusable class to work on Enumerations so that I can decorate various Enums with different attributes and I can use this class to get a particular attribute property to display....
dreza's user avatar
  • 6,417
2 votes
2 answers
2k views

Alphabetically-sorted word lookup

The goal of this code is to save a list of 250000 words with a number that indicates its frequency. The 250000 are sorted alphabetically but the frequency is unsorted. The idea is that a user must ...
user avatar
7 votes
1 answer
2k views

Optimizing Huffman Decoding

I've been working on implementing a fast Huffman decoder for video decoding. With some help from you, I have been able to produce a decent implementation. However I am still not satisfied with the ...
ronag's user avatar
  • 576
3 votes
1 answer
394 views

Method to lookup persistent entities by an example object

i'm currently writing a generic data access object for the persistent entities I have to handle in my JavaEE application. What this codeReview is about is a findByExample method that is used to find ...
unR's user avatar
  • 133