unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Freeman Gilmore <freeman.gilmore@gmail.com>
To: Mark H Weaver <mhw@netris.org>
Cc: guile-user@gnu.org
Subject: Re: Unicode numeric value
Date: Fri, 4 Jan 2019 20:07:34 -0500	[thread overview]
Message-ID: <CAM=7=uTB5UA3f8jDyQVEM_YWinhSQNZYDiVVZSu68wbojebczw@mail.gmail.com> (raw)
In-Reply-To: <87bm5kxae3.fsf@netris.org>

Mark:

I have been away and just getting back to email.   Thank you for replying.

So it looks like the library is just a lookup table.   I though it was
more  complicated than that, reading from a Unicode data file.    The hash
table may be better and more portable.   I could also change the numeric
value for the given code points as needed.    I do not know what " SRFI-4
homogeneous numeric vector" is, but I did google it, a lot there.

I am to new to this but I did copy your hash table that you made for me and
added the correction. Thanks for your time here.   I will probably be using
it (if I learn enough).

You all have a good year.
ƒg

On Mon, Dec 17, 2018 at 1:43 PM Mark H Weaver <mhw@netris.org> wrote:

> Hi,
>
> Freeman Gilmore <freeman.gilmore@gmail.com> writes:
>
> > On Sun, Dec 16, 2018 at 3:15 AM Mark H Weaver <mhw@netris.org> wrote:
> >
> >  Freeman Gilmore <freeman.gilmore@gmail.com> writes:
> >
> >  > I am looking for a procedure that will read the numeric value, field
> 8, of
> >  > an Unicode numeric character.   Has anyone written this procedure or
> know
> >  > where I can find it?
> >
> >  The 'r7rs-wip' branch of the Guile git repository contains a procedure
> >  that does this, with a lookup table derived from Unicode 6.3.0.
> >
> >
> https://git.savannah.gnu.org/cgit/guile.git/tree/module/scheme/char.scm?h=r7rs-wip
> >
> >  The file is written as an R7RS library form, which won't work on current
> >  releases of Guile, but for now you could simply extract the
> >  'digit-value' procedure from it, provided that you preserve the
> >  copyright notice.
> >
> >        Mark
> >
> > Thank you Mark:
> >
> > That is only half the battle, let me explain.  I do not want to read
> > the standard Unicode table.  I want to directly read field 8 of a
> > numeric character in the privet use area of the Unicode.
> >
> > This is not part of scheme.  The other half, I need to finger out how
> > to put the numeric values in field 8 for the characters I want to use.
>
> If the mapping from code points to numeric values is static, then you
> could simply modify the lookup table in the code I suggested above.
>
> If the mapping is dynamic, then you'll need a different strategy.  One
> simple approach would be to use a hash table mapping from characters to
> digit values:
>
>   (define digit-value-table (make-hash-table))
>
>   (define (set-digit-value! char value)
>     (hashv-set! digit-value-table char value))
>
>   (define (digit-value char)
>     (hashv-ref digit-value-table char #f))
>
> If the range of relevant code points is small enough, another approach
> would be to use a vector:
>
>   (define private-code-point-start #xE000)
>   (define private-code-point-end   #xF900)
>
>   (define (code-point-in-range? cp)
>     (<= private-code-point-start
>         cp
>         private-code-point-end))
>
>   (define digit-value-table
>     (make-vector (- private-code-point-end
>                     private-code-point-start)
>                  #f))
>
>   (define (set-digit-value! char value)
>     (let ((cp (char->integer char)))
>       (unless (code-point-in-range? cp)
>         (error "set-digit-value!: code point out of range:" cp))
>       (vector-set! digit-value-table
>                    (- cp private-code-point-start)
>                    value)))
>
>   (define (digit-value char)
>     (let ((cp (char->integer char)))
>       (and (code-point-in-range? cp)
>            (vector-ref digit-value-table
>                        (- cp private-code-point-start)))))
>
> For a more compact representation, you could use a SRFI-4 homogeneous
> numeric vector instead, although you'd need to designate a special
> numeric value to represent "not a digit".
>
>     Regards,
>       Mark
>


      parent reply	other threads:[~2019-01-05  1:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-16  4:31 Unicode numeric value Freeman Gilmore
2018-12-16  6:11 ` John Cowan
2018-12-16  8:14 ` Mark H Weaver
2018-12-16 11:24   ` Freeman Gilmore
2018-12-17 18:42     ` Mark H Weaver
2018-12-17 18:52       ` Mark H Weaver
2019-01-05  1:07       ` Freeman Gilmore [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM=7=uTB5UA3f8jDyQVEM_YWinhSQNZYDiVVZSu68wbojebczw@mail.gmail.com' \
    --to=freeman.gilmore@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=mhw@netris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).