comp.lang.ada
 help / color / mirror / Atom feed
* Neat and tidy solution to following problem?
@ 2002-05-07 18:24 chris.danx
  2002-05-07 19:17 ` Preben Randhol
  2002-05-07 20:38 ` achrist
  0 siblings, 2 replies; 8+ messages in thread
From: chris.danx @ 2002-05-07 18:24 UTC (permalink / raw)


Hi,

As part of an assignment we have to split text up into words, and check if
they're in a document.  I'm ok with the assignment I just wondered if there
was an Ada like equivalent to tuples that didn't involve defining an
explicit record type (say word_and_remaining type)?  We did a similar task
in Haskell and by passing out more than one item of different types as a
single item was very tidy and easy (see below).


Some Haskell code for a simple text function

> getWord :: String -> (String, String)
> getWord []       = ([], [])
> getWord (' ':[]) = ([], [])
> getWord (x:xs)
>    | (x == ' ')  = ([], trim xs)
>    | otherwise   = ([x] ++ selection, remList)
>      where (selection, remList) = getWord xs


I'm just wondering if there's a way to have something similar in Ada 95 like
have two items returned from a function but not have to declare an explicit
type.


Regards,
Chris

p.s. please don't post any code specific to cutting up text into words, it
could negatively impact ppls marks (and DON'T send me any code privately).

p.p.s. this isn't intended as a Haskell is better than Ada post (both are
good tools).  The intention is to find another way of doing the same task so
no language Holy Wars attributed to my post, if you don't mind.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-05-25 20:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-07 18:24 Neat and tidy solution to following problem? chris.danx
2002-05-07 19:17 ` Preben Randhol
2002-05-07 20:21   ` chris.danx
2002-05-08  1:11     ` Jeffrey Carter
2002-05-08  8:16       ` Danx
2002-05-07 20:38 ` achrist
2002-05-07 20:56   ` chris.danx
2002-05-25 20:56     ` Robert I. Eachus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox