🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.functional
2 messages
2 total messages Started by Steve Sullivan Sun, 15 Nov 1992 15:55
ml questions
#911
Author: Steve Sullivan
Date: Sun, 15 Nov 1992 15:55
46 lines
2043 bytes
I'm enjoying learning sml, and had a few
questions.  Please let me know if you can shed
any light on any of these!  Many thanks ...


1. The sml I'm using, from princeton.edu, includes Harper's notes.
His notes document the "system" and "cd" commands.
Yet sml apparently doesn't recognize them.  How can I get them working?


2.  How can I get a function to remember state?

In particular, I want to write a random number
generator that remembers it's last seed,
so the caller doesn't have to provide it.  Many modern
generators require hundreds of bytes of state info, so passing
that in and out on each call is very inefficient.

Simple example - how to get sml to do something like:

fun rand 1 = let val seed = ref 1 in !seed end   (* initialize and return 1 *)
  | rand 2 = (seed := (xx*seed) mod yy; !seed;)  (* update seed, return it *)


3. Why not allow nonlinear patterns?  They wouldn't have to cover
the whole general matching problem - just allow, for example,
   fun (x,x) = ...
to bind the first x, and then fail if the second x doesn't match.



4. Why not lazy functions?  Seems lazy and strict evaluation
could be mixed, with functions being lazy by default, and 
strict if:
  - they used any imperative features
  - they used any function which is strict
I looked at lsml from sbcs.sunysb.edu, but at first glance
it seems very experimental and somewhat out of date.


If you have light to shed on any of these, please let me
know!  Many thanks -

Steve Sullivan
sullivan@csn.org
Re: ml questions
#913
Author: Andrew Koenig
Date: Mon, 16 Nov 1992 05:59
18 lines
1021 bytes
In article <BxrLL9.A11@csn.org> sullivan@teal.csn.org (Steve Sullivan) writes:

> 1. The sml I'm using, from princeton.edu, includes Harper's notes.
> His notes document the "system" and "cd" commands.
> Yet sml apparently doesn't recognize them.  How can I get them working?

They're there, but buried in structures.  Try System.system
and System.Directory.cd

> 2.  How can I get a function to remember state?

A simple example -- perhaps too simple:

	val seed = ref 1;
	fun rand() = (seed := (xx * !seed) mod yy; !seed);
-- 
				--Andrew Koenig
				  ark@europa.att.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads