The tag has no wiki summary.

learn more… | top users | synonyms

-1
votes
0answers
11 views

Finding in std::list [migrated]

Tell me please how to do that the best using STL. I have class that has a member std::list. It's private member. I have only const_iterator to begin and end. I'd like to check if list has some ...
0
votes
1answer
71 views

Is there a design pattern for updating lists?

I want to modify one list (actually info stored in a database). A person doesn't have access to update every part of the list, but can update and delete parts they do have access to and add whatever ...
0
votes
0answers
33 views

Sorting lists (global vs local)

In my application users have lists. They can either add a new item to their list or add an item from a previous list. The set of all items I'll call G (global) (each user's global list is their own). ...
1
vote
2answers
84 views

Mapping a list of optional values to an optional list of values

I have encountered the following pattern while programming in Haskell (but the pattern could occur in any language supporting lists, option types, and mapping of a function over a list). I have types ...
1
vote
3answers
206 views

Why it is `(cons 1 (cons 2 (cons 3 nil)))` and not `(cons 3 (cons 2 (cons 1 nil)))` for [1,2,3]?

Is there any special reason that to construct list in Scheme you use (cons 1 (cons 2 (cons 3 nil))) instead of (cons 3 (cons 2 (cons 1 nil))) ? While the first seems more obvious because it ...
3
votes
2answers
1k views

Should I use a list or an array?

I'm working on a windows form to calculate UPC for item numbers. I successfully create one that will handle one item number/UPC at a time, now I want to expand and do it for multiple item ...
6
votes
1answer
347 views

Why appending to a list in Scala should have O(n) time complexity?

I am learning Scala at the moment and I just read that the execution time of the append operation for a list (:+) grows linearly with the size of the list. Appending to a list seems like a pretty ...
2
votes
2answers
86 views

Designing a user-defined list to be stored in a relational database - Should I include user index?

By index, I mean, as the user creates the list, each item receives an integer index for its place in that particular list. Since there will be a table of ListItems, I'd prefer to avoid using the name ...
2
votes
3answers
233 views

What language has integrated “list insertion” as part of code *syntax*?

Many programming languages permit natural manipulation of strings, and some languages permit the manipulations of lists too. More often then not (always?), these operations are done as procedure ...
2
votes
3answers
398 views

Best way to choose random element from weighted list

I want to create a simple game. Every so often, a power up should appear. Right now the different kinds of power ups are stored in an array. However, not every power up should appear equally often: ...
0
votes
2answers
165 views

Queues and threading

I am developing a new project where I will be constantly checking a webpage for data and adding this data to a queue for processing. This data will then be removed from the queue and added to a list ...
0
votes
0answers
142 views

Performance of a Skip-List algorithm

Here is a simple code for a randomized skip-list: Coin_Side flip() { if ( random() % 2 == 0 ) return HEADS; else return TAILS; } Note: random() returns an integer that uses ...
1
vote
2answers
136 views

Building a sequential list in languages with cons/linked lists

In languages where cons lists are a major datatype, it is very easy to create a list from last to first by prepending items. When doing processing from some input file, however, one is most likely to ...
7
votes
1answer
376 views

Origin of common list-processing function names

Some higher-order functions for operating on lists or arrays have been repeatedly adopted or reinvented. The functions map, fold[l|r], and filter are found together in several programming ...
1
vote
0answers
237 views

What is the rule on passing around collections? List vs. Ienumerable vs. IQueryable

I do Entity Framework stuff using repository patterns that are passed to the controller to than be called by the client using jquery AJAX.. Is there any basic rules on in what format I should be ...
1
vote
2answers
203 views

Multiple orders in a single list

I have a problem with a ranking system I am using. Scenario: An online game with around 10k players calculates a real time ranking of points when a certain event occurs. Events don't occur that ...
0
votes
1answer
73 views

Show all definitions in Scheme?

I want to see all user-made definitions in a Scheme REPL, both loaded from files and entered at the REPL. Is there any way to "dump all definitions"? E.g. if there is: (define (plusone x) (+ 1 ...
1
vote
1answer
216 views

Custom Alphabetic Sorting of Array in Java

I have a requirement to read a text file with lines in tag=value format and then output the file with specific tags listed first and the rest sorted alphabetically. The incoming file is randomly ...
1
vote
3answers
304 views

What can Go chan do that a list cannot?

I want to know in which situation Go chan makes code much simpler than using list or queue or array that is usually available in all languages. As it was stated by Rob Pike in one of his speeches ...
5
votes
7answers
319 views

Test driven development when implementing a flexible length list

According to the commonly used TDD strategy, to implement something, you write a test that fail the code first, write the simplest code, refactor, and then repeat. I am trying to imagine this scenario ...
1
vote
1answer
182 views

Designing a list class with filtering and sorting

The app I'm developing needs to display lists of items. Simple enough, but there are a number of things which can change based on user input: Items can be added to/removed from the list. The items ...
5
votes
2answers
474 views

Use Queue<T> or stick to native f# lists

I need something that represents a queue in F#. The queue will be filled with items once, and (as the application progresses) items will be taken from this queue and moved to other lists. Should I ...
1
vote
3answers
246 views

Random List of numbers in C

I have just started a C programming course and so far have only done the basics like printf, read a little on variables etc on the course book. The teacher has tasked us with writing a program that ...
5
votes
1answer
1k views

C++11 support for higher-order list functions

Most functional programming languages (e.g. Common Lisp, Scheme / Racket, Clojure, Haskell, Scala, Ocaml, SML) support some common higher-order functions on lists, such as map, filter, takeWhile, ...
1
vote
2answers
198 views

What does using (vec col) or (vector arg1 & args) cost?

I am working through some Lisp exercises using Clojure. If I were to convert Lisp lists to Clojure vectors, solving some of the problems would be simpler, so here is my question: Does using vec or ...
6
votes
3answers
386 views

Is there a language where collections can be used as objects without altering the behavior?

Is there a language where collections can be used as objects without altering the behavior? As an example, first, imagine those functions work: function capitalize(str) //suppose this ...
12
votes
8answers
2k views

Find a “hole” in a list of numbers

What is the fastest way to find the first (smallest) integer that doesn't exist in a given list of unsorted integers (and that is greater than the list's smallest value)? My primitive approach is ...
11
votes
4answers
616 views

Why are cons lists associated with functional programming?

I have noticed that most functional languages employ a singly-linked list (a "cons" list) as their most fundamental list types. Examples include CLisp, Haskell and F#. This is different to mainstream ...
4
votes
2answers
338 views

Is this the right strategy to convert an in-level order binary tree to a doubly linked list?

So I recently came across this question - Make a function that converts a in-level-order binary tree into a doubly linked list. Apparently, it's a common interview question. This is the strategy I ...
4
votes
3answers
789 views

Lisp: Benefits of lists as code over arrays as code?

Question for lisp programmers: Lisp code is lisp data, usually lists. Is there an advantage to code being lists over code being arrays? Would macros be easier to write/faster to run? You can ...
4
votes
6answers
5k views

How do I figure out the minimum number of swaps to sort a list in-place?

In-place sorting is essentially swapping elements without using extra storage, correct? How can I find the minimum number of swaps required for a list? A C D Q R Z E // input | | | > > ...