Talk:Range extraction

From Rosetta Code
Revision as of 18:51, 30 July 2010 by 173.29.92.176 (talk) (→‎thanks for the post: new section)

Might I suggest breaking the format description out to a separate page and transcluding it both here and in Range expansion? --Michael Mol 00:17, 16 July 2010 (UTC)

Hi Michael, do you have an example page? I'm just worried that the page with the format description might look a little 'lost' as the format is only loosely based on the relatively obscure job array index format for LSF.
I just put in a simple example implementation of what I was describing. --Michael Mol 10:42, 16 July 2010 (UTC)
I didn't know you could do that. I've added a few small edits to all three pages. --Paddy3118 12:57, 16 July 2010 (UTC)

Without Duck Typing

Hi Neville, I noted this comment from your Algol solution:

Note: The closest concept that Algol 68 has to duck typing is the tagged union. If duck typing was available it could reduced the size of the code specimen, but would have lost some of Algol 68's strong type data security.

Thinking about it, you could form and use a list of ranges for what is to become each entry in the 'rangified' internal format, where each entry range is a pair of integers. It would then only be converted to the dash separated integer range form, or two comma separated digits, or one digit, in the routine to create a correctly formed string depending if the second number minus the first number in the range is: >= 2, or ==1, or == 0.

--Paddy3118 05:24, 16 July 2010 (UTC)

I see that you are saying. Essentially the middle iterator gen range merge is actually doing this that you describe.

I inserted gen range merge in the middle of a chain of iterators. These chained iterators do the following steps:

  1. Iterate through three different types of initial arrays - []int, []range and []rangeint with gen range, yielding range(lwb,upb)
  2. Iterate with gen range merge yielding merged range(lwb,upb)
  3. Iterate with gen range int merge, merging and yielding a union of int and range
  4. Finally iterate with range int list init exiting with an array of union of int and range.

I could have just restricted the code to the behaviour of gen range merge with 'rangified' internal format, but I having used python heaps and I am endeared to the flexibility that duck typing and iterators provide to python. In this instance I am glad to be able to mimic some of the duck typing flexibility and use iterators in the much older Algol 68.

Moreover this code specimen also produces the nice "bi-product" of a family of range helper functions, and a non-trivial example of iterating in Algol 68.

NevilleDNZ 07:02, 16 July 2010 (UTC)

Thanks for the further explanation. --Paddy3118 08:14, 16 July 2010 (UTC)

Sample Output Request

Hi, without a sample of the Ocaml and Oz output, I can't check that it correctly performs the task. --Paddy3118 05:24, 17 July 2010 (UTC)

Task name

Just wondering ... Since the complementary task is "Range expansion", would a better name for this task be "Range compression" or maybe "Range contraction"? Or is extraction the usual term for this? --Snoman 06:52, 18 July 2010 (UTC)

Hmm, I don't like 'Range compression' as the phrase seems less descriptive of what is happening. It could mean too many other things. 'Range formatting' is more precise, but I like the alliteration of 'Range extraction' and 'Range expansion' so far. --Paddy3118 10:02, 18 July 2010 (UTC)

thanks for the post

Great site. A lot of useful information here. I’m sending it to some friends!