SapphireDensetsu / ypsilon

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

The "count" function does not behave as SRFI-1 specified. #155

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
None of the three examples of the "count" function in SRFI-1 works in Ypsilon 
0.9.6-update3 (from 
http://old-releases.ubuntu.com/ubuntu/pool/universe/y/ypsilon/ypsilon_0.9.6.upda
te3-7ubuntu1_amd64.deb).

> (import (srfi :1))
> (count even? '(3 1 4 1 5 9 2 5 6))

error in apply: expected proper list for last argument, but got 3

backtrace:
  0  (count even? '(3 1 4 1 5 9 2 5 6))
  ..."/dev/stdin" line 1

> (count < '(1 2 4 8) '(2 4 6 8 10 12 14 16))

error: #<closure 0x6aad82e0> expected 2, but 3 arguments given

irritants:
  (1 2 0)

backtrace:
  0  (count < '(1 2 4 8) '(2 4 6 8 10 12 14 16))
  ..."/dev/stdin" line 1

Original issue reported on code.google.com by noctuor...@gmail.com on 2 Mar 2013 at 2:33

GoogleCodeExporter commented 8 years ago
I tried to modify the "count" function defined in 
/usr/share/ypsilon/sitelib/srfi/srfi-1.scm. Not sure whether this fulfill the 
requirement of SRFI-1:

  (define count
    (lambda (proc lst1 . lst2)
      (cond ((null? lst2)
             (fold-1 (lambda (args acc)
                       (if (proc args) (+ acc 1) acc))
                     0
                     lst1))
            (else
             (fold-1 (lambda (arg acc)
                       (if (apply proc arg) (+ acc 1) acc))
                     0
                     (apply list-transpose* lst1 lst2))))))

Original comment by noctuor...@gmail.com on 2 Mar 2013 at 2:57

GoogleCodeExporter commented 8 years ago
I found the code in the SVN trunk is different from the one from .deb file.

I replace "%3a1.scm" and "srfi-1.scm" in my system with the ones from SVN. The 
first example with only one list argument works, but the following examples 
with more list arguments failed.

> (import (srfi :1))
> (count < '(1 2 4 8) '(2 4 6 8 10 12 14 16))

error: #<closure 0xb00fec0> expected 2, but 3 arguments given

irritants:
  (1 2 0)

backtrace:
  0  (count < '(1 2 4 8) '(2 4 6 8 10 12 14 16))
  ..."/dev/stdin" line 1

> (count < '(1 2 4 8) '(2 4 6 8 10 12 14 16))

error: #<closure 0x19711de0> expected 2, but 3 arguments given

irritants:
  (1 2 0)

backtrace:
  0  (count < '(1 2 4 8) '(2 4 6 8 10 12 14 16))
  ..."/dev/stdin" line 1

Original comment by noctuor...@gmail.com on 2 Mar 2013 at 3:32