HN user

brihat

20 karma
Posts1
Comments6
View on HN

Freenode #emacs, ##linux, #nimrod, #julia and #d.

Nimrod's gang (including Araq) are very friendly and welcoming.

#julia and #d are very quiet though (except for the bots).

And #emacs -- well, that one channel which is lenient towards off-topic chats!

A naive implementation in Nimrod:

     proc main(max_a0: int): int =
       var a, longest, len, max_len : int
     
       for a0 in countup(1, max_a0):
         a = a0
         len = 0
     
         while a != 1:
           len += 1
           if (a mod 2 != 0): a = (3*a + 1)
           a = a div 2
     
         if len > max_len:
           max_len = len
           longest = a0
     
       return longest
     
     # Main program starts here
     echo(main(1000000))
Takes 0.76s (the C program in TFA takes 0.58s)

The author intentionally chooses decomposed form. Indeed all of them work with Python 3. Here:

    Python 3.3.2+ (default, Oct  9 2013, 14:50:09) 
    [GCC 4.8.1] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> noel="noël"
    >>> noel[::-1]       # reverse
    'lëon'
    >>> noel[0:3]        # first three characters 
    'noë'
    >>> len(noel)        # length
    4
The point is, defining what is a character based on how it is displayed is flawed. Just precompose the string ifg you want and carry on. Like I said in my other comment, making automatic conversion of decomposed -> precomposed wrecks havoc with Indian languages.

This article is mostly written from a European language perspective. For Indian scripts, storing combining characters as a separate code points is the right thing to do.

For example, कि (ki) is composed of क and ि When I'm writing this in an editor, say, I typed ku (कु) instead of ki (कि) and I press backspace, I indeed want to see क rather than deleting the whole "कि".