POV-Ray : Newsgroups : povray.off-topic : Logic programming : Re: Some code Server Time
3 Nov 2024 01:07:38 EDT (-0400)
  Re: Some code  
From: Invisible
Date: 3 Apr 2008 07:12:59
Message: <47f4c9cb$1@news.povray.org>
Darren New wrote:

> OK. Right now I'm working on a Jotto game. That's been my "second 
> program" since high school on languages where I needed to figure out how 
> they work.  (First being "hello world" of course.)
> 
> I'm happy to post that when I finish too.

What is "Jotto"?

> I'm also trying to figure out in the back of my head how to translate a 
> bunch of the SQL stuff at work to use Mnesia, which is Erlang's database 
> system.  (Apparently, the name was originally "Amnesia" until one of the 
> managers pointed out what a bad idea it was to name a database system 
> "Amnesia." :-)

Er, yes... interesting name choice. (?!)

>> [Would you also like to see the parser and pretty printer? They're not 
>> much larger. ;-) ]
> 
> Sure. Erlang has such built in (for Erlang literals, at least), but 
> sure. :-)

Oh, it's trivial to get the compiler to write a parser for Haskell 
literals too. But the problem [in this case] is that the Haskell 
expressions are rather verbose and wordy, which makes it hard to type 
out non-trivial example expressions and so forth.

> Incidentally, any reason you can see why this with 5600 lines of input 
> would take 10 seconds and with 100,000 lines of input (20 times as big) 
> it would take more than an hour?  Am I doing something stupidly N^2 or 
> is it the memory management doing something odd?
> 
> 
> load_file_words(IO, Acc) ->
>     % Read one space-delimited string from the IO chan with no prompt
>     Read = io:fread(IO, [], "~s"),
>     case Read of
>         {ok, [[]]} -> load_file_words(IO, Acc); % blank line
>         {ok, [Word]} -> load_file_words(IO, [Word|Acc]); % found word
>         eof -> Acc; % End of file, return accumulated answers
>         {error, What} -> erlang:error(What) % crash out
>     end.
> 
> Isn't this how you're supposed to do the functional programming loop 
> bit? :)

Without knowing Erlang well enough, I couldn't speculate. It looks to me 
light it ought to work, but hey...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.