unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Re: guile studio
       [not found] <mailman.533.1624102324.10239.guile-user@gnu.org>
@ 2021-06-19 12:13 ` Kjetil Matheussen
  0 siblings, 0 replies; 12+ messages in thread
From: Kjetil Matheussen @ 2021-06-19 12:13 UTC (permalink / raw)
  To: guile-user

> From: jerry <jdinardo@nycap.rr.com>
>
> I am fairly new to guile and scheme. People tell me that I should use a
> functional style.
>
> I have 3 solutions for project euler problem #1. The first is
> functional, the second is imperative and the third is written in "Little
> Schemer" style.
>
> I was hoping other guile users would comment on preferences or the
> "correct way". Sorry in advance for any wrapping problems that may occur.
>
> #!/usr/local/bin/guile  -s
> !#
> (use-modules (srfi srfi-1) (jpd stdio)) ;; for folds
> (define N 1000)
>
> (define ans
>    (fold + 0
>      (filter
>        (lambda (x) (or (= 0 (modulo x 3)) (= 0 (modulo x 5))))
>        (iota N))))
> (print ans)
>

For minor calculations, I would say this is fine. It's not hard to
understand what this function does. However, the more complicated a
function is, the harder this style will be to read, compared to a
recursive style (example 3). So in general I would recommend never to
use fold, but that's probably somewhat a matter of taste. Personally I
never use fold.


> (define ans 0)
> (for i N
>    (if (or (= 0 (modulo i 3)) (= 0 (modulo i 5))) (set! ans (+ ans i))))
> (print ans)
>

Same here. For minor calculations, this is fine. In fact, this way is
probably much easier to read than the first example. However, if you
start using 'set!' on more than one variable, things can get very
messy. Regarding performance, this might be both faster or slower
depending on the scheme implementation.


> (define ans
>    (let loop ((i 1) (ans 0))
>      (cond
>        ((>= i N) ans)
>        ((or (= 0 (modulo i 3)) (= 0 (modulo i 5))) (loop (1+ i) (+ ans i)))
>        (else (loop (1+ i) ans)) )))
>

Please note that this way is also functional. This way is also more
efficient than example #1 since the program can do tail call
optimization and doesn't have to allocate lists. In addition, if you
had formatted this version properly I would have consider this version
to be easier to read than example #1.

Also note that if N is not too big (so that tail call optimization
doesn't matter), the following version would be even simpler:

(define ans
  (let loop ((i 1))
    (cond ((>= i N)
           0)
          ((or (= 0 (modulo i 3))
               (= 0 (modulo i 5)))
           (+ i
              (loop (1+ i))))
          (else
           (loop (1+ i))))))

Training yourself to read and write functions this way is probably a
good exercise. After a while you are able to easily make very advanced
functions by using recursive functions. Also note that using less
number of lines in a function does not make the function easier to
read.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: guile studio
  2021-06-04 11:50               ` Adriano Peluso
@ 2021-06-04 11:55                 ` Ricardo Wurmus
  0 siblings, 0 replies; 12+ messages in thread
From: Ricardo Wurmus @ 2021-06-04 11:55 UTC (permalink / raw)
  To: randomlooser; +Cc: guile-user


Adriano Peluso <randomlooser@riseup.net> writes:

>> Can you confirm that the presence of ~/.emacs.d prevents 
>> guile-studio from starting correctly?  I would then try to 
>> reproduce this and figure out how to prevent this problem.
>> 
>
>
> Well, I can't confirm
>
> In fact, I reinstated my old .emacs.d folder, the one containing 
> the
> configuration based on Straight, and now guile-studio starts up
> correctly, it seems 
>
> I can't explain this, it didn't start up properly, I swear 🤷️

Thanks for testing anyway!

-- 
Ricardo



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: guile studio
  2021-06-02 10:40             ` Ricardo Wurmus
@ 2021-06-04 11:50               ` Adriano Peluso
  2021-06-04 11:55                 ` Ricardo Wurmus
  0 siblings, 1 reply; 12+ messages in thread
From: Adriano Peluso @ 2021-06-04 11:50 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guile-user

Il giorno mer, 02/06/2021 alle 12.40 +0200, Ricardo Wurmus ha scritto:
> 
> Adriano Peluso <randomlooser@riseup.net> writes:
> 
> > Il giorno lun, 31/05/2021 alle 11.45 +0200, Ricardo Wurmus ha 
> > scritto:
> > 
> > 
> > 
> > > Hmm, this is a little confusing.  Perhaps something is missing 
> > > in 
> > > Guile Studio to prevent accidental loading of existing Emacs 
> > > packages.  The wrapper overrides EMACSLOADPATH and then 
> > > launches a 
> > > particular version of Emacs without the site file, and then 
> > > loads 
> > > all the packages from EMACSLOADPATH.  I wonder if it 
> > > accidentally 
> > > picks up *other* packages as well.
> > > 
> > 
> > Can I help in any way ?
> 
> Can you confirm that the presence of ~/.emacs.d prevents 
> guile-studio from starting correctly?  I would then try to 
> reproduce this and figure out how to prevent this problem.
> 


Well, I can't confirm

In fact, I reinstated my old .emacs.d folder, the one containing the
configuration based on Straight, and now guile-studio starts up
correctly, it seems 

I can't explain this, it didn't start up properly, I swear 🤷️




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: guile studio
  2021-06-02  9:10           ` Adriano Peluso
@ 2021-06-02 10:40             ` Ricardo Wurmus
  2021-06-04 11:50               ` Adriano Peluso
  0 siblings, 1 reply; 12+ messages in thread
From: Ricardo Wurmus @ 2021-06-02 10:40 UTC (permalink / raw)
  To: randomlooser; +Cc: guile-user


Adriano Peluso <randomlooser@riseup.net> writes:

> Il giorno lun, 31/05/2021 alle 11.45 +0200, Ricardo Wurmus ha 
> scritto:
>
>
>
>> Hmm, this is a little confusing.  Perhaps something is missing 
>> in 
>> Guile Studio to prevent accidental loading of existing Emacs 
>> packages.  The wrapper overrides EMACSLOADPATH and then 
>> launches a 
>> particular version of Emacs without the site file, and then 
>> loads 
>> all the packages from EMACSLOADPATH.  I wonder if it 
>> accidentally 
>> picks up *other* packages as well.
>> 
>
> Can I help in any way ?

Can you confirm that the presence of ~/.emacs.d prevents 
guile-studio from starting correctly?  I would then try to 
reproduce this and figure out how to prevent this problem.

-- 
Ricardo



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: guile studio
  2021-05-31  9:45         ` Ricardo Wurmus
@ 2021-06-02  9:10           ` Adriano Peluso
  2021-06-02 10:40             ` Ricardo Wurmus
  0 siblings, 1 reply; 12+ messages in thread
From: Adriano Peluso @ 2021-06-02  9:10 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guile-user

Il giorno lun, 31/05/2021 alle 11.45 +0200, Ricardo Wurmus ha scritto:



> Hmm, this is a little confusing.  Perhaps something is missing in 
> Guile Studio to prevent accidental loading of existing Emacs 
> packages.  The wrapper overrides EMACSLOADPATH and then launches a 
> particular version of Emacs without the site file, and then loads 
> all the packages from EMACSLOADPATH.  I wonder if it accidentally 
> picks up *other* packages as well.
> 

Can I help in any way ?




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: guile studio
  2021-05-30 16:56       ` Adriano Peluso
@ 2021-05-31  9:45         ` Ricardo Wurmus
  2021-06-02  9:10           ` Adriano Peluso
  0 siblings, 1 reply; 12+ messages in thread
From: Ricardo Wurmus @ 2021-05-31  9:45 UTC (permalink / raw)
  To: randomlooser; +Cc: guile-user


Adriano Peluso <randomlooser@riseup.net> writes:
> It does work !

Great!

> It's just that I had forgot a .emacs.d folder in my home (for 
> the Emacs
> provided by Ubuntu) and it was misdirecting the Emacses provided 
> by
> Guix 

Hmm, this is a little confusing.  Perhaps something is missing in 
Guile Studio to prevent accidental loading of existing Emacs 
packages.  The wrapper overrides EMACSLOADPATH and then launches a 
particular version of Emacs without the site file, and then loads 
all the packages from EMACSLOADPATH.  I wonder if it accidentally 
picks up *other* packages as well.

-- 
Ricardo



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: guile studio
  2021-05-30  6:04     ` Adriano Peluso
@ 2021-05-30 16:56       ` Adriano Peluso
  2021-05-31  9:45         ` Ricardo Wurmus
  0 siblings, 1 reply; 12+ messages in thread
From: Adriano Peluso @ 2021-05-30 16:56 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guile-user

Il giorno dom, 30/05/2021 alle 08.04 +0200, Adriano Peluso ha scritto:
> Il giorno sab, 29/05/2021 alle 22.23 +0200, Ricardo Wurmus ha
> scritto:
> > 
> > Ricardo Wurmus <rekado@elephly.net> writes:
> > 
> > > Hi Adriano,
> > > 
> > > thank you for the report!
> > > 
> > > > In this picture you can see in the minibuffer the 
> > > > writing:"Cannot
> > > > open load file: File o directory non esistente,
> > > > Ivy"
> > > 
> > > This must have been caused by another recent change in how Emacs
> > > packages work in Guix.  I’ll see if I can fix it soon.
> > 
> > This is fixed in Guix commit 
> > 036f9980c4d5db180716dadc88382b39d6fdc3cf.
> > 
> > Thanks again for taking the time to report this!
> > 
> 
> 
> ehm...
> 
> I updated (guix pull and guix package -u guile-studio)
> 
> but nothing changed 🤷️
> 
> if I do 
> 

Sorry, I was wrong

It does work !

It's just that I had forgot a .emacs.d folder in my home (for the Emacs
provided by Ubuntu) and it was misdirecting the Emacses provided by
Guix 

Now I have the complete screen with 3 panes, the REPL, a "untitled.scm"
file and the column n the right 👍️

Sorry for the noise
Thanks 





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: guile studio
  2021-05-29 20:23   ` Ricardo Wurmus
@ 2021-05-30  6:04     ` Adriano Peluso
  2021-05-30 16:56       ` Adriano Peluso
  0 siblings, 1 reply; 12+ messages in thread
From: Adriano Peluso @ 2021-05-30  6:04 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guile-user

Il giorno sab, 29/05/2021 alle 22.23 +0200, Ricardo Wurmus ha scritto:
> 
> Ricardo Wurmus <rekado@elephly.net> writes:
> 
> > Hi Adriano,
> > 
> > thank you for the report!
> > 
> > > In this picture you can see in the minibuffer the 
> > > writing:"Cannot
> > > open load file: File o directory non esistente,
> > > Ivy"
> > 
> > This must have been caused by another recent change in how Emacs
> > packages work in Guix.  I’ll see if I can fix it soon.
> 
> This is fixed in Guix commit 
> 036f9980c4d5db180716dadc88382b39d6fdc3cf.
> 
> Thanks again for taking the time to report this!
> 


ehm...

I updated (guix pull and guix package -u guile-studio)

but nothing changed 🤷️

if I do 

guix package --list-installed

the version of guile-studio now is

0.1.1-1.dd0ad42




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: guile studio
  2021-05-29 19:45 ` Ricardo Wurmus
@ 2021-05-29 20:23   ` Ricardo Wurmus
  2021-05-30  6:04     ` Adriano Peluso
  0 siblings, 1 reply; 12+ messages in thread
From: Ricardo Wurmus @ 2021-05-29 20:23 UTC (permalink / raw)
  Cc: guile-user


Ricardo Wurmus <rekado@elephly.net> writes:

> Hi Adriano,
>
> thank you for the report!
>
>> In this picture you can see in the minibuffer the 
>> writing:"Cannot
>> open load file: File o directory non esistente,
>> Ivy"
>
> This must have been caused by another recent change in how Emacs
> packages work in Guix.  I’ll see if I can fix it soon.

This is fixed in Guix commit 
036f9980c4d5db180716dadc88382b39d6fdc3cf.

Thanks again for taking the time to report this!

-- 
Ricardo



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: guile studio
  2021-05-27 11:53 Adriano Peluso
  2021-05-27 11:57 ` Adriano Peluso
@ 2021-05-29 19:45 ` Ricardo Wurmus
  2021-05-29 20:23   ` Ricardo Wurmus
  1 sibling, 1 reply; 12+ messages in thread
From: Ricardo Wurmus @ 2021-05-29 19:45 UTC (permalink / raw)
  To: randomlooser; +Cc: guile-user


Hi Adriano,

thank you for the report!

> In this picture you can see in the minibuffer 
> the writing:"Cannot open load file: File o directory non 
> esistente,
> Ivy"

This must have been caused by another recent change in how Emacs 
packages work in Guix.  I’ll see if I can fix it soon.

-- 
Ricardo



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: guile studio
  2021-05-27 11:53 Adriano Peluso
@ 2021-05-27 11:57 ` Adriano Peluso
  2021-05-29 19:45 ` Ricardo Wurmus
  1 sibling, 0 replies; 12+ messages in thread
From: Adriano Peluso @ 2021-05-27 11:57 UTC (permalink / raw)
  To: Guile User

I forgot:

this is the version of Guile studio I'm running

0.1.0-1.93622e7




^ permalink raw reply	[flat|nested] 12+ messages in thread

* guile studio
@ 2021-05-27 11:53 Adriano Peluso
  2021-05-27 11:57 ` Adriano Peluso
  2021-05-29 19:45 ` Ricardo Wurmus
  0 siblings, 2 replies; 12+ messages in thread
From: Adriano Peluso @ 2021-05-27 11:53 UTC (permalink / raw)
  To: Guile User

In this picture you can see in the minibuffer 
the writing:"Cannot open load file: File o directory non esistente,
Ivy"

https://0x0.st/-2PK.png

and in the terminal where I launched guile studio:


$ guile-studio
Gtk-Message: 13:49:52.811: Failed to load module "canberra-gtk-module"
Gtk-Message: 13:49:52.811: Failed to load module "canberra-gtk-module"

Also, guile studio shows an empty window containing the *scratch*
buffer

this is quite different from the image I see on the web site
https://elephly.net/guile-studio/

Is this expected ?

I'm running Ubuntu 20.04 and Guix on top of it and of course guile
studio is installed with Guix

Is this expected ?

Thanks




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-06-19 12:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.533.1624102324.10239.guile-user@gnu.org>
2021-06-19 12:13 ` guile studio Kjetil Matheussen
2021-05-27 11:53 Adriano Peluso
2021-05-27 11:57 ` Adriano Peluso
2021-05-29 19:45 ` Ricardo Wurmus
2021-05-29 20:23   ` Ricardo Wurmus
2021-05-30  6:04     ` Adriano Peluso
2021-05-30 16:56       ` Adriano Peluso
2021-05-31  9:45         ` Ricardo Wurmus
2021-06-02  9:10           ` Adriano Peluso
2021-06-02 10:40             ` Ricardo Wurmus
2021-06-04 11:50               ` Adriano Peluso
2021-06-04 11:55                 ` Ricardo Wurmus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).