🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #1056

Length of Arrays in SML

#1056
From: Susan E Smith
Date: Tue, 05 Jan 1993 19:49
29 lines
1656 bytes
PROBLEM:  I am using Standard ML (New Jersey), Version 0.66 and I am trying
to use the Array function "length" to get the length of an array.  I have
defined my array using arrayoflist:

	eg.	val My_Array = arrayoflist ["Hi","My","Name","Is","Bob"];

	Now I want to use "length My_Array" to return the integer 5.

The reference manual I am using, says that this can be done and that the
function length is one that takes an array and returns an int.

However, this gives me an error when I try it in my version of SML and when
I type "length;" it tells me that length accepts a list and returns an int,

	eg.	length My_List;  returns the length of the list, My_List.

	I have tested this and this is the case.

The discrepancy between my reference manual and my version of SML is not the
major concern here, what I really want to know is:  Is there a way to get
the length of an array in the version of SML I am using.  This is important
to my application because I have a statement that says My_Array sub i where
i is begin incremented; hence, once i is out of range for the array, I don't
want the function to continue executing.

Any help would be greatly appreciated.

Susan
ssmith@ug.cs.dal.ca
Technical Details
Message-ID: <C0ECE1.Ju@cs.dal.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!newsflash.concordia.ca!nstn.ns.ca!cs.dal.ca!ug.cs.dal.ca!ssmith

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.functional
Path: arc1-ca.pugleaf.net!sparky!uunet!newsflash.concordia.ca!nstn.ns.ca!cs.dal.ca!ug.cs.dal.ca!ssmith
From: ssmith@ug.cs.dal.ca (Susan E Smith)
Subject: Length of Arrays in SML
Message-ID: <C0ECE1.Ju@cs.dal.ca>
Sender: usenet@cs.dal.ca (USENET News)
Nntp-Posting-Host: ug2.cs.dal.ca
Organization: Math, Stats & CS, Dalhousie University, Halifax, NS, Canada
Date: Tue, 5 Jan 1993 19:49:12 GMT
Lines: 29