403 Forbidden & extending an Iterable

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

403 Forbidden & extending an Iterable

Jim Newton
When I try to post to https://users.scala-lang.org  I get a 403 Forbidden error.
I hope I have not been banned. :-(


Here is the question I'd like to post.


If I have two objects a and b of type Iterable[T],  what is the best way to append them?  I assume it is with a ++ b.  Is that correct?    Do I need to care about the order of the arguments of  ++? For example if I know which one is likely to be smaller than the other?

Also what is the correct way to add just one element to the Iterable? Should I use a ++ Iterable(b) or Iterable(b) ++ a ?  Or is something else better?    I tried b::a but that doesn't work.

Also what is the correct word to use for adding one object or many objects to an Iterable.  If it is a list I'd say cons and append.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 403 Forbidden & extending an Iterable

Heather Miller-2
(We were actually upgrading Discourse about 15 minutes ago, so I'd
guess you conveniently tried to post right in the middle of that :-P)

On Tue, Mar 21, 2017 at 9:54 AM, Jim Newton <[hidden email]> wrote:

> When I try to post to https://users.scala-lang.org  I get a 403 Forbidden
> error.
> I hope I have not been banned. :-(
>
>
> Here is the question I'd like to post.
>
>
> If I have two objects a and b of type Iterable[T],  what is the best way to
> append them?  I assume it is with a ++ b.  Is that correct?    Do I need to
> care about the order of the arguments of  ++? For example if I know which
> one is likely to be smaller than the other?
>
> Also what is the correct way to add just one element to the Iterable? Should
> I use a ++ Iterable(b) or Iterable(b) ++ a ?  Or is something else better?
> I tried b::a but that doesn't work.
>
> Also what is the correct word to use for adding one object or many objects
> to an Iterable.  If it is a list I'd say cons and append.
>
> --
> You received this message because you are subscribed to the Google Groups
> "scala-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 403 Forbidden & extending an Iterable

Jasper-M
In reply to this post by Jim Newton
If you have some objects of type Iterable[T] I don't think you have to care about in what order you append things. Because there's no way to know anything about the performance characteristics of the underlying data structure.

Kind regards,
Jasper

Op dinsdag 21 maart 2017 09:54:58 UTC+1 schreef Jim Newton:
When I try to post to <a href="https://users.scala-lang.org" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fusers.scala-lang.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGialPTqI0bNx-90asbcg0PBbJmPA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fusers.scala-lang.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGialPTqI0bNx-90asbcg0PBbJmPA&#39;;return true;">https://users.scala-lang.org  I get a 403 Forbidden error.
I hope I have not been banned. :-(


Here is the question I'd like to post.


If I have two objects a and b of type Iterable[T],  what is the best way to append them?  I assume it is with a ++ b.  Is that correct?    Do I need to care about the order of the arguments of  ++? For example if I know which one is likely to be smaller than the other?

Also what is the correct way to add just one element to the Iterable? Should I use a ++ Iterable(b) or Iterable(b) ++ a ?  Or is something else better?    I tried b::a but that doesn't work.

Also what is the correct word to use for adding one object or many objects to an Iterable.  If it is a list I'd say cons and append.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 403 Forbidden & extending an Iterable

Stephen Compall-3
On 3/21/17 4:54 AM, Jim Newton wrote:
If I have two objects a and b of type Iterable[T],  what is the best way to append them?  I assume it is with a ++ b.  Is that correct?    Do I need to care about the order of the arguments of  ++? For example if I know which one is likely to be smaller than the other?
Well, in general, a ++ b != b ++ a, so the answer is "whichever gives the right answer".  I suspect there is some more context missing here, though, such as an iterated append.
Also what is the correct way to add just one element to the Iterable? Should I use a ++ Iterable(b) or Iterable(b) ++ a ?  Or is something else better?    I tried b::a but that doesn't work.
a +: b (a element, b seq) is a good choice.  But at this level of expectation, you should probably be working with at least seq instead of iterable.
Also what is the correct word to use for adding one object or many objects to an Iterable.  If it is a list I'd say cons and append.
"append" works well for combining two, and "cons" for adding to the beginning of a seq.  A good word for adding an element to the end is "snoc" (I am being so sincere right now).

On 3/21/17 6:19 AM, Jasper-M wrote:
If you have some objects of type Iterable[T] I don't think you have to care about in what order you append things. Because there's no way to know anything about the performance characteristics of the underlying data structure.
I half-suspect Jim is referring to an iterated append, in which case the ordering does matter, because even though you don't know exactly, you can try for reasonable average outcomes.

The following summary is less scientific than it may at first appear.  It is certainly incomplete:


left-fold
balanced fold
right-fold
List
O(n²)
O(n log₂n) O(n)
Vector
O(n log₂n) O(n log₂n) O(n log₂n)
Array
O(n²)
O(n log₂n) O(n²)

(The left-fold for Vector is optimized IIRC, but this is an artifact of its partial implementation, not the data structure's intrinsic characteristics.)

--
Stephen Compall

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...