juan_gandhi: (VP)
[personal profile] juan_gandhi
  def parameters(href): Map[String, String] = href split("\\?",2) toList match {
    case url::params::Nil => params.split("&") map (_ split "=" toList) collect {
      case k::v::Nil => k->v
    } toMap

    case otherwise => Map.empty  
  }


Or?...

Date: 2014-08-12 04:27 am (UTC)
From: [identity profile] jdevelop.livejournal.com
wouldn't catch the case when param1=value1&param1=value2

also & will break everything

I'd suggest to use URL from Apache HttpClient.
Edited Date: 2014-08-12 04:27 am (UTC)

Date: 2014-08-12 04:31 am (UTC)
From: [identity profile] juan-gandhi.livejournal.com
Why would not it catch the case?
And I despise the whole Apache HttpClient anyway.

Date: 2014-08-12 04:34 am (UTC)
From: [identity profile] jdevelop.livejournal.com
because you have multiple values for same parameter, which is legal - and you'r code will get only last one.

as for & - this is a valid code block for encoding the ampersand in the parameter name or value.

Date: 2014-08-12 05:06 am (UTC)
From: [identity profile] juan-gandhi.livejournal.com
Right. Well, have to think about it.

Date: 2014-08-13 01:00 am (UTC)
From: [identity profile] http://users.livejournal.com/_xacid_/
use List[(String, String)] as result

:)

Date: 2014-08-12 04:32 am (UTC)
From: [identity profile] juan-gandhi.livejournal.com
Well, this is more serious, of course. :)

Date: 2014-08-12 05:44 am (UTC)
From: [identity profile] mikkim08.livejournal.com
I'd suggest to use

Только без "to". Можно говорить "suggest (you) use" или "suggest using", а "suggest to use" -- нельзя.

Я это говорю только потому, что когда исправляют, лучше запоминается.
Edited Date: 2014-08-12 05:45 am (UTC)

Date: 2014-08-12 09:45 pm (UTC)
From: [identity profile] juan-gandhi.livejournal.com
http://www.englishteachermelanie.com/grammar-how-to-use-the-verb-suggest/

Date: 2014-08-12 08:53 pm (UTC)
From: [identity profile] yussouf.livejournal.com
what does these toLists toMaps cost?

Date: 2014-08-12 09:13 pm (UTC)
From: [identity profile] juan-gandhi.livejournal.com
I would not say I care. Converting max 1k of data from one form to another...

Date: 2014-08-12 10:29 pm (UTC)
From: [identity profile] yussouf.livejournal.com
that's apparently a wicked thinking to me

which you functionalistz are (very) usually tend to fall into
everything is to be sacrificed to the that notorious "expressiveness" again

PS even if you're personally very aware of what exactly is going on in this particular case and are pretty 100% sure that the data structures won't exceed the reasonable size of that 1K (and the number of that stuff processed in parallel would also be reasonable) - it is STILL a wicked thinking

Date: 2014-08-12 11:37 pm (UTC)
From: [identity profile] juan-gandhi.livejournal.com
Ok, but I don't care! I have other things on mind.

Date: 2014-08-13 12:21 am (UTC)
From: [identity profile] badula.livejournal.com
At some point in our talks I asked Schwarze­negger how much time he had spent, as governor, grappling with the on-the-ground local implications of the big state crisis. The question pretty clearly bored him. “I’m not into the local stuff,” he’d said. “I was born for the world.” (http://www.vanityfair.com/business/features/2011/11/michael-lewis-201111)
Edited Date: 2014-08-13 12:21 am (UTC)

Date: 2014-08-13 01:07 am (UTC)
From: [identity profile] http://users.livejournal.com/_xacid_/
I know several imperativists who don't care even more

Date: 2014-08-13 01:56 am (UTC)
From: [identity profile] yussouf.livejournal.com
I know several dozens of 'em - so what the heck does it prove? :-)

Date: 2014-08-13 11:38 am (UTC)
From: [identity profile] http://users.livejournal.com/_xacid_/
nothing, of course

Date: 2014-08-12 09:37 pm (UTC)
From: [identity profile] badula.livejournal.com
the costs are mainly infrastructural, because all data is immutable, the only added cost is the one of calling through the shitload of intermediate iterators
not sure how lazy the "split" thing is in scala. the sample goes through all iterators sequentially

Date: 2014-08-12 10:18 pm (UTC)
From: [identity profile] yussouf.livejournal.com
the split produces just mere Java mutable Array of strings afair

so, that happened to be the full copy of data, no reuse

Date: 2014-08-12 11:05 pm (UTC)
From: [identity profile] badula.livejournal.com
The complexity is still linear. That is in most cases what matters. In some other cases instead of 5000 servers one may have to have 10000 suckers. At which point the additional operational expenses should be but trivial.

Date: 2014-08-13 12:24 am (UTC)
From: [identity profile] http://users.livejournal.com/_xacid_/
why not parsers combinators? :)

Date: 2014-08-13 12:30 am (UTC)
From: [identity profile] juan-gandhi.livejournal.com
Sure it would work; but this is a regular language anyway (why not a regex?)

Date: 2014-08-13 12:47 am (UTC)
From: [identity profile] http://users.livejournal.com/_xacid_/
indeed :) moreover, they both work great together

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

June 2025

S M T W T F S
1 2345 6 7
8 9 10 11 121314
15161718 1920 21
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 27th, 2025 06:38 pm
Powered by Dreamwidth Studios