For Programmers: Free Programming Magazines  


Home > Archive > Fortran > August 2005 > Re: Reduce Blanks challenge









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Reduce Blanks challenge
robin

2005-08-20, 9:56 pm


David Frank wrote in message ...
>we can go on to a 2nd challenge thats been running concurrently over in
>comp.lang.fortran.
>Posted only for PLI'er info, there wont be a PL/I translation.


>Since its my challenge I am narrowing the acceptable solutions in reduce.f90
>as follows:
>
>1. the output string must contain a blank last char (if input string has 1
>or more trailing blanks)
> by output of a null char after just 1 trailing blank char is output.
>2. the solution must use array syntax, no scalar processing with do loops
>3. Fast/Legible/Brief is a goal.
>
>If you want to submit or resubmit a solution that meets these revisions, be
>my guest, sometime next w
>I will kick out existing solutions that dont meet above specs, leaving room
>for new entries.
>
>My current solution that meets these revised specs, uses 3 statements:



No it doesn't. It uses 22 statements, made up of three plus the 19 statements
in COPY :-

INTERFACE Copy
MODULE PROCEDURE copy_a2s, copy_s2a
END INTERFACE CopyCONTAINS
! ------------------------
FUNCTION Copy_a2s(a) RESULT (s) ! copy char array to string
CHARACTER :: a(:)
CHARACTER(SIZE(a)) :: s
INTEGER :: i
DO i = 1,SIZE(a)
s(i:i) = a(i)
END DO
END FUNCTION Copy_a2s
! ------------------------
FUNCTION Copy_s2a(s) RESULT (a) ! copy string to char array
CHARACTER(*) :: s
CHARACTER :: a(LEN(s))
INTEGER :: i
DO i = 1,LEN(s)
a(i) = s(i:i)
END DO
END FUNCTION Copy_s2a

>pad = char(0) ! allow pack to use null chars to pad its output
>a = Copy(line) ! copy line to char array
>outline = line(1:1) // Copy( PACK(a(2:), a(2:)/=' '.or.a(1:)/=' ',pad) )



David Frank

2005-08-21, 7:56 am


"robin" <robin_v@bigpond.com> wrote in message
news:RJRNe.5955$FA3.3343@news-server.bigpond.net.au...
>


>
> No it doesn't. It uses 22 statements, made up of three plus the 19
> statements
> in COPY :-
>


Future users write 1 line...

a = Copy(line) or s = Copy(a)

they could care less that Copy source has 3 executable statements that have
been pre-compiled into a module
that can be linked to other user programs, or added to a user library. But
you know this, you are just blathering as usual covering up the
short-comings in your fav language's syntax.

You have stated that PL/I supports generic routines, but when asked to show
code, refuse to do so.
Here's another chance, show Fortran'ers and your DEVOTED PL/I readership
YOUR generic Copy function.



Rich Townsend

2005-08-21, 6:57 pm

David Frank wrote:
> "robin" <robin_v@bigpond.com> wrote in message
> news:RJRNe.5955$FA3.3343@news-server.bigpond.net.au...
>
>
>
>
> Future users write 1 line...
>
> a = Copy(line) or s = Copy(a)
>
> they could care less that Copy source has 3 executable statements that have
> been pre-compiled into a module
> that can be linked to other user programs, or added to a user library. But
> you know this, you are just blathering as usual covering up the
> short-comings in your fav language's syntax.


So you are now claiming that it is permissible, in your language
challenges, to use user-defined language functions that *don't* count
against the number of lines in a solution.

Fair enough.

Here is my winning 1-liner for blank reduction:

outline = REDUCE_BLANKS(line)

The function REDUCE_BLANKS() is a module routine -- it can be linked to
other user programs, or added to a user library. Before I provide the
source code for this incredibly fast routine, YOU must show me your routine.

cheers,

Rich
David Frank

2005-08-21, 6:57 pm


"Rich Townsend" <rhdt@barVOIDtol.udel.edu> wrote in message
news:dea1pa$p1j$1@scrotar.nss.udel.edu...
short-comings in your fav language's syntax.
>
> So you are now claiming that it is permissible, in your language
> challenges, to use user-defined language functions that *don't* count
> against the number of lines in a solution.
>
> Fair enough.
>
> Here is my winning 1-liner for blank reduction:
>
> outline = REDUCE_BLANKS(line)
>
> The function REDUCE_BLANKS() is a module routine -- it can be linked to
> other user programs, or added to a user library. Before I provide the
> source code for this incredibly fast routine, YOU must show me your
> routine.
>
> cheers,
>
> Rich


My OFFICIAL ENTRY in the challenge is already in a module by that name where
you can view the source.

http://home.earthlink.net/~dave_gemini/strings.f90

and has been there for about 2 ws now getting occasional updates but it
looks like its now finalized.

The benchmark code at:
http://home.earthlink.net/~dave_gemini/reduce.f90 USEs string_functions
in strings.f90 file including my reduce_blanks function, Where have you
been?

If you want to submit your REDUCE_BLANKS_TOWNSEND function to be entered in
the reduce.f90 benchmark,
be my guest, but there are new rules, (use array syntax, return 1 trailing
blank)
AND yes, you can use ANY aids you see in string_functions including just a
duplication of my function IF you have a modification that allows it to run
a little faster, so have a go, say what! (that applies to anyone)..


robin

2005-08-24, 3:57 am

David Frank wrote in message ...
>
>"robin" <robin_v@bigpond.com> wrote in message
>news:RJRNe.5955$FA3.3343@news-server.bigpond.net.au...
[color=darkred]
>You have stated that PL/I supports generic routines, but when asked to show
>code, refuse to do so.


That's a falsehood, and you know it.

>Here's another chance, show Fortran'ers and your DEVOTED PL/I readership
>YOUR generic Copy function.



In PL/I it's the standard built-in function and pseudo-variable called STRING.


David Frank

2005-08-24, 3:57 am


"robin" <robin_v@bigpond.com> wrote in message
news:lESOe.8629$FA3.5976@news-server.bigpond.net.au...
> David Frank wrote in message ...
>
>
> That's a falsehood, and you know it.
>
>
>
> In PL/I it's the standard built-in function and pseudo-variable called
> STRING.
>
>


Are you forgetting that comp.lang.pl1 is archived and is a great DE-LIAR,
there are no hits for "GENERIC"
that lead to code examples from pli'ers, just from myself showing Fortran
examples.



robin

2005-08-24, 7:56 am


David Frank wrote in message ...
>
>"robin" <robin_v@bigpond.com> wrote in message
>news:lESOe.8629$FA3.5976@news-server.bigpond.net.au...
>
>Are you forgetting that comp.lang.pl1 is archived and is a great DE-LIAR,
>there are no hits for "GENERIC"
>that lead to code examples from pli'ers,


You wouldn't recognize one even if it sat on you.

> just from myself showing Fortran examples.



The search is only as reliable as your search engine,
and depend on whether all postings have, in fact, been archived.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com