Any Haskellers here?
How would you rewrite the following function in Guile?
foo :: [Int] -> String -> [Int]
foo (x:y:ys) "+" = (x + y):ys
foo (x:y:ys) "-" = (x - y):ys
foo xs num = read num:xs
*Main> foo [] "42"
[42]
*Main> foo [1,2] "42"
[42,1,2]
*Main> foo [1,2] "+"
[3]
*Main> foo [1..10
On 9 February 2013 17:57, Nikita Karetnikov wrote:
> Any Haskellers here?
>
> How would you rewrite the following function in Guile?
>
> foo :: [Int] -> String -> [Int]
> foo (x:y:ys) "+" = (x + y):ys
> foo (x:y:ys) "-" = (x - y):ys
> foo xs num = read num:xs
Indeed, match can do this. The
On 9 February 2013 18:12, Daniel Hartwig wrote:
> Using symbols and literals, rather than strings:
Though strings work just as well as symbols :-)
Nikita Karetnikov writes:
> How would you rewrite the following function in Guile?
>
> foo :: [Int] -> String -> [Int]
> foo (x:y:ys) "+" = (x + y):ys
> foo (x:y:ys) "-" = (x - y):ys
> foo xs num = read num:xs
Daniel covered most of this already, but instead you might consider
(define foo
> the nearest analogue to read is object->string, but it is not a generic.
That should be string->object. It's funny how often I mix up a->b and b->a
--
Ian Price -- shift-reset.com
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy
Well it seems I may have been premature in saying that srfi-1 was
successfully loaded. Although the error message is gone, there is no
symbol 'map which srfi-1 should have re-defined.
Can someone suggest what this might be a symptom of?
Denemo has a command line interpreter for guile, so I can fe
Richard Shann writes:
> Well it seems I may have been premature in saying that srfi-1 was
> successfully loaded. Although the error message is gone, there is no
> symbol 'map which srfi-1 should have re-defined.
> Can someone suggest what this might be a symptom of?
I know what's wrong. Please
Richard Shann writes:
> Well it seems I may have been premature in saying that srfi-1 was
> successfully loaded. Although the error message is gone, there is no
> symbol 'map which srfi-1 should have re-defined.
> Can someone suggest what this might be a symptom of?
I wrote:
> I know what's wro
At Sat, 2 Feb 2013 23:24:38 +0100,
Richard Braun wrote:
> On Sat, Feb 02, 2013 at 07:51:38PM +0100, Gabriel Schnoering wrote:
> > I can't run guile in gdb as there are some error with the garbage
> > collector.
>
> These are probably not errors. Many language interpretors rely on
> receiving SIGSE
On Sat, 2013-02-09 at 10:32 -0500, Mark H Weaver wrote:
> Richard Shann writes:
> > Well it seems I may have been premature in saying that srfi-1 was
> > successfully loaded. Although the error message is gone, there is no
> > symbol 'map which srfi-1 should have re-defined.
> > Can someone sugge
More on that call to
scm_c_call_with_current_module (scm_c_resolve_module ("srfi srfi-1"),
init_srfi_1, NULL);
I have had a look using gdb and it is exiting during the call to
scm_c_resolve_module()
HTH
Richard
Hi Richard,
Don't worry, we'll get it working. Here's another attempt.
Replace the calls to 'scm_c_register_extension' with the following:
scm_c_call_with_current_module (scm_c_resolve_module ("guile"),
bind_srfi_initializers, NULL);
With the following additi
12 matches
Mail list logo