Re: [Chicken-users] Port of racket/math to Chicken egg

2019-06-27 Thread Sungjin Chun
Wow, this is great!
On Jun 27, 2019, 15:31 +0900, Diego , wrote:
> I've begun to port https://docs.racket-lang.org/math/index.html to a Chicken 
> Scheme egg here:
>
> https://github.com/dieggsy/chicken-math
>
> math.number-theory (equivalent to math/number-theory in racket) is finished 
> with tests passing, so at least that should be usable. Development on the 
> rest has stalled a bit as I haven't quite figured out how to port all the 
> special syntax in some modules.
>
> I'd like to add this to the egg repository, as long as it's ok that it's 
> technically not 'complete' at this point. I'm also wondering wether a more 
> descriptive name than simply 'math' would be better (e.g. racket-math?) so as 
> to avoid ambiguity or confusion.
>
> - Diego
>
>
>
> ___
> Chicken-users mailing list
> Chicken-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/chicken-users
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] Macro for defining function from string

2019-04-05 Thread Sungjin Chun
Hi,
In writing FFI module for C library there’s too much repetition; so I’d like to 
write some
macro to reduce this repetition.

What I’d like to write is something as follows: (define-my-bindings …)

(define-my-bindinngs “Float”) should emit following code.

(define float-xxx-xxx (foreign-lambda float (string-append “TH” “Float” 
“Storage_xxx”))

What I cannot do now is generating float-xxx-xxx like function id from 
“float-xxx-xxx” string.

How can I convert string to the id? 

Thanks in advance.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] Overhead of FFI in Chicken scheme

2019-02-10 Thread Sungjin Chun
Hi,

Are there any FFI overhead in case of compiling to a binary using "bind"?
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] Are there any performance-wise differences between Chicken 5 and Chicken 4?

2018-10-10 Thread Sungjin Chun
Hi, it seems that Chicken 5 will be released soon or else :-) I'd like to
know
whether there's any performance enhancement in Chicken 5 compared to
Chicken 4.

Thanks in advance.

PS)
I'd like to port my library to Chicken scheme (for fun) and the library is
located at https://bitbucket.org/chunsj/th/ . Mostly, this library uses FFI
to the underlying libTH and libTHNN from torch. Are there any reference
on writing FFI code in Chicken scheme?

Thanks you again.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] Can I make port on byte array?

2015-10-06 Thread Sungjin Chun
Hi,

In Common Lisp, I can make a stream on byte array and can write
values on them, in Scheme, I think the equivalent stuff is port and
I'd like to write values on byte array using port.

Can anyone help me on finding documents or samples?

Thanks in advance and sorry for my poor english.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] How can I convert this lisp(SBCL) macro to chicken scheme?

2014-11-06 Thread Sungjin Chun
Hi,

I've rather impressed on Clojure's easy to use hash and vector/array, I've
written
and used these macros in my lisp code. Now I want to convert them for
chicken.

(set-macro-character
  #\{
  (lambda (stream char)
(declare (ignore char))
(let ((*readtable* (copy-readtable *readtable* nil)))
  (set-macro-character #\} (get-macro-character #\)))
  (set-macro-character #\, (lambda (stream char)
 (declare (ignore stream char))
 (values)))
  (set-macro-character #\~ (get-macro-character #\,))
  (let ((contents (read-delimited-list #\} stream t))
(ht (gensym)))
`(let ((,ht (make-hash-table :test #'equal :synchronized t)))
   ,@(loop for (k v) on contents by #'cddr
collect `(setf (gethash ,k ,ht) ,v))
   ,ht)

(set-macro-character
  #\[
  (lambda (stream char)
(declare (ignore char))
(let ((*readtable* (copy-readtable *readtable* nil)))
  (set-macro-character #\] (get-macro-character #\)))
  (set-macro-character #\, (lambda (stream char)
 (declare (ignore stream char))
 (values)))
  (set-macro-character #\~ (get-macro-character #\,))
  (let ((contents (read-delimited-list #\] stream t)))
`(vector ,@contents)

How can I convert this macros to chicken, where can I find introductory
docs on macro
of chicken scheme?

Thank you in advance.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] [Q] How can I convert this lisp(SBCL) macro to chicken scheme?

2014-11-06 Thread Sungjin Chun
Thank you. Though I'm not sure on my code is in good style, I managed to
convert my
code to chicken scheme like this;

(set-read-syntax!
 #\[
 (lambda (port)
   (let loop ((c (peek-char port)) (exps '()))
 (cond ((eof-object? c)
(error EOF encountered while parsing [ ... ] clause))
   ((char=? c #\])
(read-char port) ;
discard

`(vector ,@(reverse exps)))
   ((char-whitespace? c)
(read-char port) ; discard
whitespaces

(loop (peek-char port) exps))
   (else
(let ((exp (read port)))
  (loop (peek-char port)
(cons exp exps

(print (with-input-from-string [1 2 3 4 5] read))

(set-read-syntax!
 #\{
 (lambda (port)
   (let loop ((c (peek-char port)) (exps '()))
 (cond ((eof-object? c)
(error EOF encountered while parsing [ ... ] clause))
   ((char=? c #\})
(read-char port) ;
discard

`(alist-hash-table (chop (list ,@(reverse exps)) 2)))
   ((char-whitespace? c)
(read-char port) ; discard
whitespaces

(loop (peek-char port) exps))
   ((char=? c #\,)
(read-char port) ; discard
whitespaces

(loop (peek-char port) exps))
   (else
(let ((exp (read port)))
  (loop (peek-char port)
(cons exp exps

(print (with-input-from-string {'a 10, 'b 20, 'c 30} read))
(print (with-input-from-string {'a 10 'b 20 'c 30} read))

I post these code for people with similar needs like myself :-).


On Fri, Nov 7, 2014 at 10:33 AM, Evan Hanson ev...@foldling.org wrote:

 Hi Sungjin,

 These are typically referred to as reader extensions in the Scheme
 world: http://api.call-cc.org/doc/library#sec:Reader_extensions

 You'll probabably want `set-read-syntax!` in particular:
 http://api.call-cc.org/doc/library/set-read-syntax!

 Cheers,

 Evan

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] Can I do this in Scheme(set-macro-character thing)?

2013-09-10 Thread Sungjin Chun
I'm using following macro in lisp(SBCL) for it's convenient (at least for
me).
Can I do this in chicken scheme? Thank you in advance.

(set-macro-character
  #\[
  (lambda (stream char)
(declare (ignore char))
(let ((*readtable* (copy-readtable *readtable* nil)))
  (set-macro-character #\] (get-macro-character #\)))
  (set-macro-character #\, (lambda (stream char)
 (declare (ignore stream char))
 (values)))
  (set-macro-character #\~ (get-macro-character #\,))
  (let ((contents (read-delimited-list #\] stream t)))
`(vector ,@contents)
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] Are there any egg for timer based scheduler like cron?

2013-09-04 Thread Sungjin Chun
Hi,

I want to create a program which do some tasks with following condition;

1. During 08:00 to 16:00 (hour) of each day,
2. the task will run every 2 seconds (or minutes or so).

The time for completing task is very tiny, for example 0.01ms to 1 sec. In
Lisp(SBCL),
I have used timer package but I cannot find equivalent one for chicken
scheme.

Thanks in advance.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] How can I limit print level and length?

2013-06-28 Thread Sungjin Chun
Hi,

I want to set the limit of the length of printed string. In SLIME(for SBCL)
I can do this
with following;

(setq *PRINT-LEVEL* 10)
(setq *PRINT-LENGTH* 20)

How can I do this with Chicken Scheme (in chicken-slime in Emacs)?

Thank you in advance.
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] Why this simple code does not run?

2013-04-09 Thread Sungjin Chun
(sort '(1 2 3 4 5 6 7 8 9) )

I can run this code in the interpreter env. and I can even compile
this using chicken scheme compiler, however if I run the result binary,
it emits following error message;

Error: unbound variable: sort

   Call history:

   sort.scm:1: sort--

What should I do?
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] [Q] Why this simple code does not run?

2013-04-09 Thread Sungjin Chun
Thank you. And sometimes I have to include srfi-1 for drop and others.


On Wed, Apr 10, 2013 at 11:39 AM, Matt Gushee m...@gushee.net wrote:

 On Tue, Apr 9, 2013 at 8:26 PM, Sungjin Chun chu...@gmail.com wrote:

  Error: unbound variable: sort
 
 Call history:
 
 sort.scm:1: sort--
 
  What should I do?

 You should begin the file with

   (use data-structures)

 HTH.

 --
 Matt Gushee

 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] [Q] Is there any library for machine/statistical learning in Scheme(chicken scheme)?

2013-03-26 Thread Sungjin Chun
Thank you for your suggestions; what I've interested in is using ML for
financial time series prediction such as stock price movement forecasting
for pattern matching for trading.


On Wed, Mar 27, 2013 at 1:27 AM, Andrei Barbu and...@0xab.com wrote:

 On Mon, Mar 25, 2013 at 11:18 PM, Sungjin Chun chu...@gmail.com wrote:
  What I've found are (for chicken scheme):
  1. libsvm
  2. fann

 Are you looking for anything in particular?

 I do AI/machine-learning/robotics/computer-vision research using
 scheme-c and chicken. I've got lots of code that I haven't yet ported
 to chicken so I might have what you're looking for.

 You might be interested in
 https://github.com/abarbu/AD
  computes derivatives of programs, useful if you're optimizing a hairy
 cost function
 https://github.com/abarbu/csp
  solves constraint satisfaction problems

 There are a few AI-related eggs that I haven't yet officially released:
 https://github.com/abarbu/nlopt
  provides bindings to nlopt, which is a great library for non-linear
 optimization
 https://github.com/abarbu/matlab-chicken
  give you access to a huge library of code
 https://github.com/abarbu/ccv-chicken
   ccv is a state-of-the-art computer vision library
 https://github.com/abarbu/stochastic-discrete
  performs inference on probabilistic programs whose support is
 discrete, so if you've got a graphical model with discrete
 distributions this should be useful
 https://github.com/abarbu/matplotlib
  bindings to python's matplotlib so you can actually see what's going on



 Andrei

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] Is there any library for machine/statistical learning in Scheme(chicken scheme)?

2013-03-25 Thread Sungjin Chun
What I've found are (for chicken scheme):
1. libsvm
2. fann
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] [Q] uri-common has problem with UTF-8 uri.

2013-01-14 Thread Sungjin Chun
Thank you very much. :-)

My proposed hack(yes, no solution) just works for me but I found that it is
just wrong w.r.t RFC.
I'll try your modification and and let you know whether it works or not.

Thank you again.


On Mon, Jan 14, 2013 at 5:08 PM, Ivan Raikov ivan.g.rai...@gmail.comwrote:

 Hi Sungjin,

Thanks for trying to use the uri-generic library. As Peter already
 pointed out, uri-generic and uri-common are intended to implement RFC 3986
 (URIs), and so far no effort has been done to support RFC 3987 (IRIs).
 However, the IRI RFC does define a mapping from IRI to URI, where Unicode
 characters in IRIs are converted to percent  encoded UTF-8 sequences. The
 caveat here is that if you try to decode these percent-encoded sequences
 they will likely result in invalid URI characters. I have prototyped a
 procedure iri-uri which attempts to percent-encode all UTF-8 sequences in
 the input string and create a URI. You can see it here:


 http://bugs.call-cc.org/browser/release/4/uri-generic/branches/utf8/uri-generic.scm

 You can try iri-uri as follows:

 (use uri-generic)
 (print (iri-uri http://example.com/삼계탕;))
 (URI scheme=http authority=#(URIAuth host=example.com port=#f) path=(/
 �%82%BC�%B3%84�%83%95) query=#f fragment=#f)

   Note that the URI constructor still tries to percent-decode all
 characters in the path, and in this example this results in unprintable
 characters being displayed. So I will probably need to add a field to the
 URI structure that indicates if UTF-8 sequences are included and avoid
 percent-decoding altogether. Would this be sufficient for your needs?

   Your proposed solution to extend the definition of the 'unstructured'
 character set is in line with RFC 3987, but I need to look some more at the
 code and see whether it would be possible to have an API where the user can
 choose whether to use IRIs or URIs. I prefer not to use UTF-8 sequences by
 default, since this might result in uri-generic based client sending
 invalid URIs to a server. Let me know what the exact requirements of your
 application are, and perhaps we can some up with a simple solution.

   Ivan



 On Mon, Jan 14, 2013 at 1:36 PM, Sungjin Chun chu...@gmail.com wrote:

 As far as I know, revised RFC permits UTF-8 characters in the URL without
 encoding. Am I wrong here?
 Even Solr (the search engine) permits them.



 On Mon, Jan 14, 2013 at 1:26 PM, Alex Shinn alexsh...@gmail.com wrote:

 Hi,

 On Mon, Jan 14, 2013 at 12:52 PM, Sungjin Chun chu...@gmail.com wrote:

 First, I might have found wrong place but...

 It seems that the main source of the my problem is related to the part
 of uri-generic.scm, especially;

 (define char-set:uri-unreserved
   (char-set union char-set:letter+digit (string-char-set -_.~)))

 If I change this part as;

 (define char-set:uri-unreserved
   (char-set union char-set:letter+digit (string-char-set -_.~)
 char-set:hangul))

 then, uri/url with korean characters work. How can I set those part
 more generic one?


 I believe the ASCII definition is correct even for Unicode URLs.
 You need to represent the URL in utf8 and then use percent
 escapes on the utf8 bytes, which is what would happen naturally
 here.

 --
 Alex



 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] [Q] uri-common has problem with UTF-8 uri.

2013-01-14 Thread Sungjin Chun
My intention is to create search client for Solr (search server using
lucene); where I should send
request URL like this;

  http://127.0.0.1:8983/solr/select?q=삼계탕start=0rows=10

I've tried to create this client using http-client egg and had found that
it does not like UTF-8 characters
in the URL, so has my journey to hack started.

If you have better approach than this, I'll be appreciated :-)


On Tue, Jan 15, 2013 at 11:45 AM, Alex Shinn alexsh...@gmail.com wrote:

 On Tue, Jan 15, 2013 at 7:35 AM, Sungjin Chun chu...@gmail.com wrote:

 Thank you very much. :-)

 My proposed hack(yes, no solution) just works for me but I found that it
 is just wrong w.r.t RFC.
 I'll try your modification and and let you know whether it works or not.

 Thank you again.


 On Mon, Jan 14, 2013 at 5:08 PM, Ivan Raikov ivan.g.rai...@gmail.comwrote:

 Hi Sungjin,

Thanks for trying to use the uri-generic library. As Peter already
 pointed out, uri-generic and uri-common are intended to implement RFC 3986
 (URIs), and so far no effort has been done to support RFC 3987 (IRIs).


 Interesting, I wasn't even aware of RFC 3987.  Note that this extension
 only applies to new schemes - in particular IRIs cannot be used for HTTP.


  However, the IRI RFC does define a mapping from IRI to URI, where
 Unicode characters in IRIs are converted to percent  encoded UTF-8
 sequences. The caveat here is that if you try to decode these
 percent-encoded sequences they will likely result in invalid URI
 characters. I have prototyped a procedure iri-uri which attempts to
 percent-encode all UTF-8 sequences in the input string and create a URI.
 You can see it here:


 This shouldn't be needed.  Sungjin was using uri-common, which already
 percent-encodes UTF-8 sequences, which is what is desired.

 Sungjin - going back to your original question, what did you try and
 what did it do differently from what you expected?  This should just be
 working.

 --
 Alex


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] [Q] uri-common has problem with UTF-8 uri.

2013-01-13 Thread Sungjin Chun
For testing solr, lucene based client, I have to create url which contains 
utf-8 encoding(for Korean). But having this encoding uri-common cannot create 
uri. 

Can any one help me on this? Thanks.

Sent from my iPhone
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] [Q] uri-common has problem with UTF-8 uri.

2013-01-13 Thread Sungjin Chun
Though I'm not that fluent in scheme, I'll try to make test case for
uri-generic with UTF-8 string.

Thanks.


On Mon, Jan 14, 2013 at 7:15 AM, Peter Bex peter@xs4all.nl wrote:

 On Mon, Jan 14, 2013 at 07:04:05AM +0900, Sungjin Chun wrote:
  For testing solr, lucene based client, I have to create url which
 contains utf-8 encoding(for Korean). But having this encoding uri-common
 cannot create uri.
 
  Can any one help me on this? Thanks.

 Hello Sungjin,

 As far as I recall, there's no special facility for IRIs
 (internationalized URIs, a separate RFC from 3986) in uri-generic.
 uri-generic is the underlying egg which actually handles all the
 parsing, uri-common just adds some convenience procedures for
 HTTP and URI-encoded forms.  Maybe you can take a look at the
 uri-geneirc library, and verify it really is going wrong there already?

 If it doesn't work, some test cases would be appreciated.  We can have
 a look at them and see where it's failing.  I'm unsure whether this
 really should be supported by the uri-generic egg or whether it would
 be better to create an iri-generic egg, or some such.

 Perhaps Ivan can chime in?  He is the one who originally ported the
 code from a Haskell library, and might know whether that library had
 any known problems with IRIs (if it's even IRIs we're talking about!)

 Cheers,
 Peter
 --
 http://sjamaan.ath.cx

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] [Q] uri-common has problem with UTF-8 uri.

2013-01-13 Thread Sungjin Chun
First, I might have found wrong place but...

It seems that the main source of the my problem is related to the part of
uri-generic.scm, especially;

(define char-set:uri-unreserved
  (char-set union char-set:letter+digit (string-char-set -_.~)))

If I change this part as;

(define char-set:uri-unreserved
  (char-set union char-set:letter+digit (string-char-set -_.~)
char-set:hangul))

then, uri/url with korean characters work. How can I set those part more
generic one?

Thank you in advance and sorry for my poor english.



On Mon, Jan 14, 2013 at 7:15 AM, Peter Bex peter@xs4all.nl wrote:

 On Mon, Jan 14, 2013 at 07:04:05AM +0900, Sungjin Chun wrote:
  For testing solr, lucene based client, I have to create url which
 contains utf-8 encoding(for Korean). But having this encoding uri-common
 cannot create uri.
 
  Can any one help me on this? Thanks.

 Hello Sungjin,

 As far as I recall, there's no special facility for IRIs
 (internationalized URIs, a separate RFC from 3986) in uri-generic.
 uri-generic is the underlying egg which actually handles all the
 parsing, uri-common just adds some convenience procedures for
 HTTP and URI-encoded forms.  Maybe you can take a look at the
 uri-geneirc library, and verify it really is going wrong there already?

 If it doesn't work, some test cases would be appreciated.  We can have
 a look at them and see where it's failing.  I'm unsure whether this
 really should be supported by the uri-generic egg or whether it would
 be better to create an iri-generic egg, or some such.

 Perhaps Ivan can chime in?  He is the one who originally ported the
 code from a Haskell library, and might know whether that library had
 any known problems with IRIs (if it's even IRIs we're talking about!)

 Cheers,
 Peter
 --
 http://sjamaan.ath.cx

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] [Q] uri-common has problem with UTF-8 uri.

2013-01-13 Thread Sungjin Chun
As far as I know, revised RFC permits UTF-8 characters in the URL without
encoding. Am I wrong here?
Even Solr (the search engine) permits them.


On Mon, Jan 14, 2013 at 1:26 PM, Alex Shinn alexsh...@gmail.com wrote:

 Hi,

 On Mon, Jan 14, 2013 at 12:52 PM, Sungjin Chun chu...@gmail.com wrote:

 First, I might have found wrong place but...

 It seems that the main source of the my problem is related to the part of
 uri-generic.scm, especially;

 (define char-set:uri-unreserved
   (char-set union char-set:letter+digit (string-char-set -_.~)))

 If I change this part as;

 (define char-set:uri-unreserved
   (char-set union char-set:letter+digit (string-char-set -_.~)
 char-set:hangul))

 then, uri/url with korean characters work. How can I set those part more
 generic one?


 I believe the ASCII definition is correct even for Unicode URLs.
 You need to represent the URL in utf8 and then use percent
 escapes on the utf8 bytes, which is what would happen naturally
 here.

 --
 Alex


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users