Re: [racket-users] Questions Regarding My First Program

2021-02-23 Thread 'John Clements' via Racket Users
I *always* use DrRacket… but I admit I may not understand the indenting part of 
your question. 

In DrRacket, when you hit the “tab” key, it should move the text on the line to 
the “correct” position, according to Racket’s indentation rules. Also, whenever 
you hit return, the cursor should be automatically indented to the appropriate 
column. Finally, you can highlight a block of text and hit “tab”, and it will 
all be re-indented.

Is this different from what you’re observing, or from what you’re expecting?

John Clements

> On Feb 23, 2021, at 4:05 PM, Sage Gerard  wrote:
> 
> I can't speak to DrRacket since I never use it, so I'll focus more on the 
> first question.
> 
> Functional programming typically deals with these considerations (among 
> others):
> 
>   • Write functions that return values purely in terms of arguments.
>   • Defer side-effects until you can't.
> A goal to make the program produce the same output given the same input, 
> every time.
> 
> One example would be to redefine `say` such that it doesn't immediately 
> print. Maybe just return the string you want said.
> 
> (define (say str)
>   (format "Chatbot: ~a\n" str))
> 
> (I'd personally use a struct representing a message, sender, etc. but that's 
> beside the point)
> 
> This change makes the function "pure" in that the same input returns the same 
> output, and there are no side-effects in doing so. But this creates a problem 
> where you need to "rope in" that value somewhere. How that happens depends on 
> the program. A program that reports download progress will handles 
> side-effects differently than a program that prints a report before stopping.
> 
> One approach is to update program state in the same (functional) way. If we 
> assume the chat history is a list, where the first element is the most recent 
> message, then this version of `say` adds a string to the chat.
> 
> (define (say chat-history str)
>   (cons (format "Chatbot: ~a\n" str) 
> chat-history))
> 
> I'd start with this kind of thinking until you get to the point where 
> side-effects are unavoidable. Since your program appears interactive, you can 
> still print in the loop. But think about what your program would be like if 
> you print ONLY in that loop.
> 
> Others can probably say more, but hopefully this helps you start.
> 
> On 2/23/21 5:59 PM, IF Karona wrote:
>> Hi everyone,
>> 
>> I am new here, and I have a couple of questions related to the code that 
>> follows this message.
>> 
>> 1. I want to learn functional programming. When it comes to solving the 
>> problem of making a simple chatbot such as this, is there an approach that 
>> is more consistent with functional programming?
>> 2. I would prefer to not have to use multiple spaces every time I want to 
>> indent. Does Dr. Racket have anything comparable to the tab functionality of 
>> other programs?
>> 
>> Thank you for letting me join your community!
>> 
>> Karona
>> 
>> ;example.rkt
>> 
>> #lang racket
>> 
>> (require racket/match)
>> 
>> (define (say str)
>> (printf "Chatbot: ~a\n" str))
>> 
>> (define (handle-input str)
>> (cond
>>   
>> [(regexp-match #px"(?i:Hello,* world!)" str)
>> (say "I would not know about the rest of the world, but I can 
>> hear \
>> you just fine.")]
>>   
>> [(regexp-match #px"(?i:I( am|'m) learning how to program in Racket,* 
>> world!)" str)
>> (say "Racket is a great language, and it is lovely that you are \
>> learning it, but does literally everyone need to know?")]
>> 
>> [(regexp-match #px".*,+\\s*world!" str)
>> (say "Did the whole world really need to hear that?")]
>>   
>> [else (say "Did you really just say something without addressing the 
>> \
>> world? I am so proud of you! :,)")]))
>> 
>> (let loop ()
>> (display "Input: ")
>> (define str (read-line (current-input-port) 'any))
>> (handle-input str)
>> (loop))
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/2f107ab5-2efd-4c33-83f6-eb5751664cb6n%40googlegroups.com.
> --
> ~slg
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/d3da9796-979d-cad9-36e5-91380939630c%40sagegerard.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.

Re: [racket-users] Questions Regarding My First Program

2021-02-23 Thread Sage Gerard
I can't speak to DrRacket since I never use it, so I'll focus more on the first 
question.

Functional programming typically deals with these considerations (among others):

- Write functions that return values purely in terms of arguments.
- Defer side-effects until you can't.

A goal to make the program produce the same output given the same input, every 
time.

One example would be to redefine `say` such that it doesn't immediately print. 
Maybe just return the string you want said.

(define (say str)
(format "Chatbot: ~a\n" str))

(I'd personally use a struct representing a message, sender, etc. but that's 
beside the point)

This change makes the function "pure" in that the same input returns the same 
output, and there are no side-effects in doing so. But this creates a problem 
where you need to "rope in" that value somewhere. How that happens depends on 
the program. A program that reports download progress will handles side-effects 
differently than a program that prints a report before stopping.

One approach is to update program state in the same (functional) way. If we 
assume the chat history is a list, where the first element is the most recent 
message, then this version of `say` adds a string to the chat.

(define (say chat-history str)
(cons (format "Chatbot: ~a\n" str)
chat-history))

I'd start with this kind of thinking until you get to the point where 
side-effects are unavoidable. Since your program appears interactive, you can 
still print in the loop. But think about what your program would be like if you 
print ONLY in that loop.

Others can probably say more, but hopefully this helps you start.

On 2/23/21 5:59 PM, IF Karona wrote:

> Hi everyone,
>
> I am new here, and I have a couple of questions related to the code that 
> follows this message.
>
> 1. I want to learn functional programming. When it comes to solving the 
> problem of making a simple chatbot such as this, is there an approach that is 
> more consistent with functional programming?
> 2. I would prefer to not have to use multiple spaces every time I want to 
> indent. Does Dr. Racket have anything comparable to the tab functionality of 
> other programs?
>
> Thank you for letting me join your community!
>
> Karona
>
> ;example.rkt
>
> #lang racket
>
> (require racket/match)
>
> (define (say str)
> (printf "Chatbot: ~a\n" str))
>
> (define (handle-input str)
> (cond
>
> [(regexp-match #px"(?i:Hello,* world!)" str)
> (say "I would not know about the rest of the world, but I can hear \
> you just fine.")]
>
> [(regexp-match #px"(?i:I( am|'m) learning how to program in Racket,* world!)" 
> str)
> (say "Racket is a great language, and it is lovely that you are \
> learning it, but does literally everyone need to know?")]
>
> [(regexp-match #px".*,+\\s*world!" str)
> (say "Did the whole world really need to hear that?")]
>
> [else (say "Did you really just say something without addressing the \
> world? I am so proud of you! :,)")]))
>
> (let loop ()
> (display "Input: ")
> (define str (read-line (current-input-port) 'any))
> (handle-input str)
> (loop))
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> [https://groups.google.com/d/msgid/racket-users/2f107ab5-2efd-4c33-83f6-eb5751664cb6n%40googlegroups.com](https://groups.google.com/d/msgid/racket-users/2f107ab5-2efd-4c33-83f6-eb5751664cb6n%40googlegroups.com?utm_medium=email_source=footer).

--
~slg

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/d3da9796-979d-cad9-36e5-91380939630c%40sagegerard.com.


[racket-users] Questions Regarding My First Program

2021-02-23 Thread IF Karona
Hi everyone,

I am new here, and I have a couple of questions related to the code that 
follows this message.

1. I want to learn functional programming. When it comes to solving the 
problem of making a simple chatbot such as this, is there an approach that 
is more consistent with functional programming?
2. I would prefer to not have to use multiple spaces every time I want to 
indent. Does Dr. Racket have anything comparable to the tab functionality 
of other programs?

Thank you for letting me join your community!

Karona

;example.rkt

#lang racket

(require racket/match)

(define (say str)
(printf "Chatbot: ~a\n" str))

(define (handle-input str)
(cond
  
[(regexp-match #px"(?i:Hello,* world!)" str)
(say "I would not know about the rest of the world, but I can 
hear \
you just fine.")]
  
[(regexp-match #px"(?i:I( am|'m) learning how to program in 
Racket,* world!)" str)
(say "Racket is a great language, and it is lovely that you are 
\
learning it, but does literally everyone need to know?")]

[(regexp-match #px".*,+\\s*world!" str)
(say "Did the whole world really need to hear that?")]
  
[else (say "Did you really just say something without addressing 
the \
world? I am so proud of you! :,)")]))

(let loop ()
(display "Input: ")
(define str (read-line (current-input-port) 'any))
(handle-input str)
(loop))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2f107ab5-2efd-4c33-83f6-eb5751664cb6n%40googlegroups.com.


Re: [racket-users] public email addresses on packages server

2021-02-23 Thread Sam Tobin-Hochstadt
Github doesn't require making your email address public.

Sam

On Tue, Feb 23, 2021 at 12:19 PM Hendrik Boom  wrote:
>
> On Sat, Feb 20, 2021 at 11:47:19PM +0700, Roger Keays wrote:
> > Has any consideration been given to concealing email addresses on 
> > pkgs.racket-lang.org for privacy purposes?
>
> Aren't those email addresses available anyway from github?
>
> -- hendrik
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/20210223171932.ljgqq77qb5b7wjin%40topoi.pooq.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAK%3DHD%2BY840OarKctMC6Hpjb1-TYC6ZLmC6F2aeeZtrmnbykLSg%40mail.gmail.com.


Re: [racket-users] flomat -- possible typo in documentation

2021-02-23 Thread Jens Axel Søgaard
Den tir. 23. feb. 2021 kl. 14.39 skrev Hendrik Boom :

> On
> https://docs.racket-lang.org/manual-flomat/index.html#%28part._.Matrix_.Creation%29
>
> it says
>
> > (sub! A i j m n)
> > Same as sub, but the elements are copied - the underlying array of
> flonums are shared.
>
> Presumably it should say "are not copied".
>

Thanks! The docs are now fixed.

/Jens Axel

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CABefVgxJL3MCOWLLVQQ2Wem5i1O6gKUMw1M91wEs5baBkLaA%2Bg%40mail.gmail.com.


Re: [racket-users] public email addresses on packages server

2021-02-23 Thread Hendrik Boom
On Sat, Feb 20, 2021 at 11:47:19PM +0700, Roger Keays wrote:
> Has any consideration been given to concealing email addresses on 
> pkgs.racket-lang.org for privacy purposes?

Aren't those email addresses available anyway from github?

-- hendrik

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20210223171932.ljgqq77qb5b7wjin%40topoi.pooq.com.


Re: [racket-users] can't create a new package on pkgd.racket-lang.org

2021-02-23 Thread Sam Tobin-Hochstadt
Unfortunately, it's old versions of Racket that don't support this,
and adding error messages there will have the same problem as fixing
them -- they're already out there and on people's computers. However,
this will be fixed in the next release of Racket.

Sam

On Tue, Feb 23, 2021 at 6:49 AM Roger Keays  wrote:
>
>
> Thanks for the pointer. Adding "main" as the branch fixed the problem with 
> the package submission too. An error message to catch that mistake might save 
> the next person some head-scratching. As far as I remember, github created my 
> repo with main as the default branch rather than master.
>
> On Fri, Feb 19, 2021 at 07:54:51PM +0700, Sorawee Porncharoenwase wrote:
> > For the raco pkg install error, it looks like your branch is named main, so
> > you need to run raco pkg install git://
> > github.com/rogerkeays/racket-dollar#main
> >
> > Ideally, raco pkg install git://github.com/rogerkeays/racket-dollar should
> > also work, but currently it doesn’t
> > .
> >
> > On Fri, Feb 19, 2021 at 6:52 PM Roger Keays  wrote:
> >
> > >
> > > Hi,
> > >
> > > Today I made an account on racket-lang.org to post a package, but when I
> > > submit the form, it just bounces back at me, blank. The package I added
> > > does not appear under "my packages", so it seems the submission failed.
> > > There are no error messages.
> > >
> > > https://pkgd.racket-lang.org/pkgn/create
> > >
> > > I'm submitting an example #lang extension from github for
> > > educational/demonstration purposes:
> > > https://github.com/rogerkeays/racket-dollar
> > >
> > > Could this be because my account is new? I also noticed I get an error
> > > when trying to get raco to install from github:
> > >
> > > $ raco pkg install git://github.com/rogerkeays/racket-dollar#master
> > > Querying Git references for racket-dollar at git://
> > > github.com/rogerkeays/racket-dollar#master
> > > git: could not find requested reference
> > >   reference: master
> > >   context...:
> > >/usr/share/racket/collects/net/git-checkout.rkt:344:0: select-commits
> > >/usr/share/racket/collects/net/git-checkout.rkt:73:8
> > >/usr/share/racket/collects/net/git-checkout.rkt:54:2: retry-loop
> > >/usr/share/racket/collects/pkg/private/stage.rkt:59:2: lookup-normally
> > >/usr/share/racket/collects/pkg/private/stage.rkt:107:0:
> > > stage-package/info46
> > >/usr/share/racket/collects/pkg/private/install.rkt:659:4: for-loop
> > >/usr/share/racket/collects/pkg/private/install.rkt:141:0:
> > > install-packages76
> > >
> > >  
> > > /usr/share/racket/collects/pkg/private/../../racket/private/more-scheme.rkt:261:28
> > >
> > >  
> > > /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt:430:3
> > >/usr/share/racket/collects/racket/file.rkt:435:8
> > >/usr/share/racket/collects/racket/file.rkt:391:2: loop
> > >/usr/share/racket/collects/pkg/main.rkt:206:16
> > >(submod "/usr/share/racket/collects/pkg/main.rkt" main): [running body]
> > >temp37_0
> > >for-loop
> > >run-module-instance!125
> > >...
> > >
> > > $ racket -v
> > > Welcome to Racket v7.2.
> > >
> > > Suggestions welcome.
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Racket Users" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an
> > > email to racket-users+unsubscr...@googlegroups.com.
> > > To view this discussion on the web visit
> > > https://groups.google.com/d/msgid/racket-users/sigid.16823f523d.20210217164232.GA4731%40papaya.papaya
> > > .
> > >
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/racket-users/CADcuegtie4M_Cjjycvc15hbfSN98HQxcNZZYH4LUxW5kfPUviA%40mail.gmail.com.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/sigid.06852a6d4b.20210220163029.GB8013%40papaya.papaya.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAK%3DHD%2BZOqsHwjuzJHrBC%2B1A59FjsvnvYDhPsG5HQQot21HiAvA%40mail.gmail.com.


[racket-users] flomat -- possible typo in documentation

2021-02-23 Thread Hendrik Boom
On Mon, Feb 22, 2021 at 10:26:09PM -0800, Rohan Posthumus wrote:
> > Just in case you haven't found them already, if you need matrices over 
> > real floating points,
> > take a look at:
> >
> > https://docs.racket-lang.org/manual-flomat/index.html

Looked at that.

On 
https://docs.racket-lang.org/manual-flomat/index.html#%28part._.Matrix_.Creation%29

it says

> (sub! A i j m n)
> Same as sub, but the elements are copied - the underlying array of flonums 
> are shared.

Presumably it should say "are not copied".

-- hendrik

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20210223133908.xyj5ndwpmwpsf4kh%40topoi.pooq.com.


Re: [racket-users] can't create a new package on pkgd.racket-lang.org

2021-02-23 Thread Roger Keays


Thanks for the pointer. Adding "main" as the branch fixed the problem with the 
package submission too. An error message to catch that mistake might save the 
next person some head-scratching. As far as I remember, github created my repo 
with main as the default branch rather than master.

On Fri, Feb 19, 2021 at 07:54:51PM +0700, Sorawee Porncharoenwase wrote:
> For the raco pkg install error, it looks like your branch is named main, so
> you need to run raco pkg install git://
> github.com/rogerkeays/racket-dollar#main
> 
> Ideally, raco pkg install git://github.com/rogerkeays/racket-dollar should
> also work, but currently it doesn’t
> .
> 
> On Fri, Feb 19, 2021 at 6:52 PM Roger Keays  wrote:
> 
> >
> > Hi,
> >
> > Today I made an account on racket-lang.org to post a package, but when I
> > submit the form, it just bounces back at me, blank. The package I added
> > does not appear under "my packages", so it seems the submission failed.
> > There are no error messages.
> >
> > https://pkgd.racket-lang.org/pkgn/create
> >
> > I'm submitting an example #lang extension from github for
> > educational/demonstration purposes:
> > https://github.com/rogerkeays/racket-dollar
> >
> > Could this be because my account is new? I also noticed I get an error
> > when trying to get raco to install from github:
> >
> > $ raco pkg install git://github.com/rogerkeays/racket-dollar#master
> > Querying Git references for racket-dollar at git://
> > github.com/rogerkeays/racket-dollar#master
> > git: could not find requested reference
> >   reference: master
> >   context...:
> >/usr/share/racket/collects/net/git-checkout.rkt:344:0: select-commits
> >/usr/share/racket/collects/net/git-checkout.rkt:73:8
> >/usr/share/racket/collects/net/git-checkout.rkt:54:2: retry-loop
> >/usr/share/racket/collects/pkg/private/stage.rkt:59:2: lookup-normally
> >/usr/share/racket/collects/pkg/private/stage.rkt:107:0:
> > stage-package/info46
> >/usr/share/racket/collects/pkg/private/install.rkt:659:4: for-loop
> >/usr/share/racket/collects/pkg/private/install.rkt:141:0:
> > install-packages76
> >
> >  
> > /usr/share/racket/collects/pkg/private/../../racket/private/more-scheme.rkt:261:28
> >
> >  
> > /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt:430:3
> >/usr/share/racket/collects/racket/file.rkt:435:8
> >/usr/share/racket/collects/racket/file.rkt:391:2: loop
> >/usr/share/racket/collects/pkg/main.rkt:206:16
> >(submod "/usr/share/racket/collects/pkg/main.rkt" main): [running body]
> >temp37_0
> >for-loop
> >run-module-instance!125
> >...
> >
> > $ racket -v
> > Welcome to Racket v7.2.
> >
> > Suggestions welcome.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/racket-users/sigid.16823f523d.20210217164232.GA4731%40papaya.papaya
> > .
> >
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CADcuegtie4M_Cjjycvc15hbfSN98HQxcNZZYH4LUxW5kfPUviA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/sigid.06852a6d4b.20210220163029.GB8013%40papaya.papaya.


[racket-users] public email addresses on packages server

2021-02-23 Thread Roger Keays
Has any consideration been given to concealing email addresses on 
pkgs.racket-lang.org for privacy purposes?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/sigid.1685d8b22b.20210220164714.GA8480%40papaya.papaya.