Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

To err is human, to forgive, beyond the scope of the Operating System.


devel / comp.lang.fortran / Bob task on Exercism

SubjectAuthor
* Bob task on ExercismBruce Axtens
`* Re: Bob task on ExercismJRR
 `- Re: Bob task on ExercismBruce Axtens

1
Bob task on Exercism

<bad07fb5-51cc-42c5-8f57-4fd20d0ef523n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3217&group=comp.lang.fortran#3217

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:6db:b0:6ef:1b80:ac9b with SMTP id 27-20020a05620a06db00b006ef1b80ac9bmr2742941qky.773.1673859878269;
Mon, 16 Jan 2023 01:04:38 -0800 (PST)
X-Received: by 2002:a05:6808:2811:b0:359:b4bd:890a with SMTP id
et17-20020a056808281100b00359b4bd890amr5539041oib.175.1673859877937; Mon, 16
Jan 2023 01:04:37 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 16 Jan 2023 01:04:37 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=60.231.231.174; posting-account=1W9SuAoAAAApKJ8N7QNszANYOyWIVzjG
NNTP-Posting-Host: 60.231.231.174
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bad07fb5-51cc-42c5-8f57-4fd20d0ef523n@googlegroups.com>
Subject: Bob task on Exercism
From: bruce.axtens@gmail.com (Bruce Axtens)
Injection-Date: Mon, 16 Jan 2023 09:04:38 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3171
 by: Bruce Axtens - Mon, 16 Jan 2023 09:04 UTC

I'm having a hard time finding some help on Exercism with this FORTRAN task.

The link to the task's mentoring portal is at https://exercism.org/mentoring/external_requests/a5e5ee1e-08d0-11ec-81c5-853579c25f94 if any can be bothered.

Alternatively, with respect to the code below I'm having difficulty with the following two tests:
! Test 18: silence
call assert_equal("Fine. Be that way!", hey(""), "silence")
! Test 19: prolonged silence
call assert_equal("Fine. Be that way!", hey(" "), "prolonged silence")

I can't figure out why the my is_silence doesn't work.

-- Bruce

module bob
implicit none

contains

function is_shouted(statement)
logical :: is_shouted
character (len=*), intent(in) :: statement

if (scan(statement,"ABCDEFGHIJKLMNOPQRSTUVWXYZ") .gt. 0) then
if (scan(statement,"abcdefgijklmnopqrstuvwxyz") .eq. 0) then
is_shouted = .TRUE.
return
end if
end if
is_shouted = .FALSE.
end function is_shouted

function is_question(statement)
logical :: is_question
character (len=*), intent(in) :: statement
character (len=len(statement)) :: temp
temp = trim(statement)
is_question = scan(temp, "?", .TRUE.) .eq. len(temp)
end function is_question

function is_silence(statement)
logical :: is_silence
character (len=*), intent(in) :: statement
is_silence = len(statement) .eq. 0
end function is_silence

function hey(statement)
character(100) :: hey
character(len=*), intent(in) :: statement
character(len(trim(statement))) :: trimmed_statement
trimmed_statement = trim(statement)
if (is_shouted(trimmed_statement)) then
if (is_question(trimmed_statement)) then
hey = "Calm down, I know what I'm doing!"
return
else
hey = "Whoa, chill out!"
return
end if
end if

if (is_question(trimmed_statement)) then
hey = "Sure."
return
end if

if (is_silence(trimmed_statement)) then
hey = "Fine. Be that way!"
return
end if

hey = "Whatever."
end function hey

end module bob

Re: Bob task on Exercism

<tq3iuq$11ip$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3218&group=comp.lang.fortran#3218

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!UPlKLdzRMTTAqqdU7iR3oA.user.46.165.242.91.POSTED!not-for-mail
From: juergen.reuter@invalid.com (JRR)
Newsgroups: comp.lang.fortran
Subject: Re: Bob task on Exercism
Date: Mon, 16 Jan 2023 14:20:26 +0100
Organization: Aioe.org NNTP Server
Message-ID: <tq3iuq$11ip$1@gioia.aioe.org>
References: <bad07fb5-51cc-42c5-8f57-4fd20d0ef523n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="34393"; posting-host="UPlKLdzRMTTAqqdU7iR3oA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: JRR - Mon, 16 Jan 2023 13:20 UTC

On 1/16/23 10:04, Bruce Axtens wrote:
> I'm having a hard time finding some help on Exercism with this FORTRAN task.
>
> The link to the task's mentoring portal is at https://exercism.org/mentoring/external_requests/a5e5ee1e-08d0-11ec-81c5-853579c25f94 if any can be bothered.
>
> Alternatively, with respect to the code below I'm having difficulty with the following two tests:
> ! Test 18: silence
> call assert_equal("Fine. Be that way!", hey(""), "silence")
> ! Test 19: prolonged silence
> call assert_equal("Fine. Be that way!", hey(" "), "prolonged silence")
>
> I can't figure out why the my is_silence doesn't work.
>

'Doesn't work' is not a very precise statement because an outsider
cannot know what you expected the is_silence function to do, nor what
you found it to do.
So I can only speculate: e.g. Metcalf/Reid, Modern
Fortran explained, Sec. 9.6.3, says
scan (string, set [,kind]) returns an integer whose value is the
position of a character of string that is in set, or zero if there is
no such character. Probably you confused the two arguments of scan.
In any case you input trimmed spaces to the first argument, which is the
empty character. Per definition, this is not contained in "?", so get
zero and your is_question function returns "Sure."

> -- Bruce
>

--
Juergen Reuter
Theoretical Particle Physics
Deutsches Elektronen-Synchrotron
Hamburg, Germany
---------------------------------
invalid is desy .and. com is de

Re: Bob task on Exercism

<89332f7f-5995-457c-b6d6-13ec561d62f5n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3219&group=comp.lang.fortran#3219

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ae9:eb11:0:b0:706:1cd6:24a4 with SMTP id b17-20020ae9eb11000000b007061cd624a4mr92859qkg.213.1673964877164;
Tue, 17 Jan 2023 06:14:37 -0800 (PST)
X-Received: by 2002:aca:2405:0:b0:364:c70e:61ac with SMTP id
n5-20020aca2405000000b00364c70e61acmr160935oic.88.1673964876853; Tue, 17 Jan
2023 06:14:36 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 17 Jan 2023 06:14:36 -0800 (PST)
In-Reply-To: <tq3iuq$11ip$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=49.196.253.140; posting-account=1W9SuAoAAAApKJ8N7QNszANYOyWIVzjG
NNTP-Posting-Host: 49.196.253.140
References: <bad07fb5-51cc-42c5-8f57-4fd20d0ef523n@googlegroups.com> <tq3iuq$11ip$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <89332f7f-5995-457c-b6d6-13ec561d62f5n@googlegroups.com>
Subject: Re: Bob task on Exercism
From: bruce.axtens@gmail.com (Bruce Axtens)
Injection-Date: Tue, 17 Jan 2023 14:14:37 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1390
 by: Bruce Axtens - Tue, 17 Jan 2023 14:14 UTC

On Monday, 16 January 2023 at 9:20:30 pm UTC+8, JRR wrote:
> On 1/16/23 10:04, Bruce Axtens wrote:
> 'Doesn't work' is not a very precise statement because an outsider

Ah, yes, that is not exactly helpful.

Nevertheless, thank you for your patience.

Bruce

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor