Quantcast
Channel: cons operator (::) in F# - Stack Overflow
Browsing latest articles
Browse All 8 View Live

Answer by Jack Fox for cons operator (::) in F#

Try using a double-ended queue instead of list. I recently added 4 versions of deques (Okasaki's spelling) to FSharpx.Core (Available through NuGet. Source code at FSharpx.Core.Datastructures). See my...

View Article



Answer by forki23 for cons operator (::) in F#

Maybe you want to use another data structure. We have double-ended queues (or short "Deques") in fsharpx. You can read more about them at http://jackfoxy.com/double-ended-queues-for-fsharp

View Article

Answer by Norman Ramsey for cons operator (::) in F#

The cost of appending two standard lists is proportional to the length of the list on the left. In particular, the cost ofxs @ [x]is proportional to the length of xs—it is not a constant cost.If you...

View Article

Answer by Brian for cons operator (::) in F#

Lists in F# are singly-linked and immutable. This means consing onto the front is O(1) (create an element and have it point to an existing list), whereas snocing onto the back is O(N) (as the entire...

View Article

Answer by Tomas Petricek for cons operator (::) in F#

As others said, there is no such operator, because it wouldn't make much sense. I actually think that this is a good thing, because it makes it easier to realize that the operation will not be...

View Article


Answer by Brian Agnew for cons operator (::) in F#

The efficiency (or lack of) comes from iterating through the list to find the final element. So declaring a new list with [4] is going to be negligible for all but the most trivial scenarios.

View Article

Answer by sepp2k for cons operator (::) in F#

I'm guessing that using @ operator [...] would be less efficient, than appending one element.If it is, it will be a negligible difference. Both appending a single item and concatenating a list to the...

View Article

cons operator (::) in F#

The :: operator in F# always prepends elements to the list. Is there an operator that appends to the list? I'm guessing that using @ operator [1; 2; 3] @ [4]would be less efficient, than appending one...

View Article

Browsing latest articles
Browse All 8 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>