20 karma · joined Nov 25, 2013 (13y ago) · 7 submissions
1.
Nimrod: A New Systems Programming Language(drdobbs.com ↗)
10 points · by brihat · 12y ago · discuss
comment 12y ago · link · parent
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)comment 13y ago · link · parent
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.comment 13y ago · link · parent
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 "कि".
comment 13y ago · link · parent
[1]: https://store.continuum.io/cshop/anaconda/
[2]: Packages: http://docs.continuum.io/anaconda/pkgs.html