Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gast
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
gast
Commits
a6089b89
Commit
a6089b89
authored
Aug 07, 2018
by
Mart Lubbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate ggenString so that it can be modified
parent
83f28313
Pipeline
#13135
passed with stage
in 36 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
Libraries/Gast/Gen.dcl
Libraries/Gast/Gen.dcl
+12
-0
Libraries/Gast/Gen.icl
Libraries/Gast/Gen.icl
+8
-5
No files found.
Libraries/Gast/Gen.dcl
View file @
a6089b89
...
...
@@ -39,6 +39,18 @@ generic ggen a :: !GenState -> [a]
genState
::
GenState
/**
* Generates an infinite list of random strings
*
* @param The maximum length of the strings
* @param The factor for which the probability decreases for longer strings
* @param Minimum character value
* @param Maximum character value
* @param A list of random numbers (e.g. aStream)
* @result An inifinite list of strings
*/
ggenString
::
Int
Real
Int
Int
RandomStream
->
[
String
]
derive
ggen
Int
,
Bool
,
Real
,
Char
,
String
derive
ggen
UNIT
,
PAIR
,
EITHER
,
CONS
of
gcd
,
OBJECT
of
gtd
,
FIELD
of
d
,
RECORD
of
grd
derive
ggen
(,),
(,,),
(,,,),
(,,,,),
(,,,,,),
(,,,,,,),
(,,,,,,,)
...
...
Libraries/Gast/Gen.icl
View file @
a6089b89
...
...
@@ -186,19 +186,22 @@ where
Nothing
->
f
s
Just
limit
->
take
limit
$
f
s
ggen
{|
String
|}
s
=
[
"hello world!"
,
"Gast"
,
""
:
rndStrings
aStream
]
ggenString
::
Int
Real
Int
Int
RandomStream
->
[
String
]
ggenString
maxlen
factor
minchar
maxchar
stream
=
rndStrings
stream
where
rndStrings
[
len
:
rnd
]
#
len
=
toInt
((
randIntToReal
len
)
^
8.0
*
(
fromInt
StrL
en
-
0.5
))
#
len
=
toInt
((
randIntToReal
len
)
^
factor
*
(
fromInt
maxl
en
-
0.5
))
#
(
chars
,
rnd
)
=
seqList
(
repeatn
len
genElem
)
rnd
string
=
{
c
\\
c
<-
chars
}
=
[
string
:
rndStrings
rnd
]
where
genElem
::
RandomStream
->
.(
Char
,
RandomStream
)
genElem
[
r
:
rnd
]
=
(
toChar
(
32
+((
abs
r
)
rem
94
)),
rnd
)
genElem
[
r
:
rnd
]
=
(
toChar
(
minchar
+((
abs
r
)
rem
(
maxchar
-
minchar
)
)),
rnd
)
randIntToReal
::
Int
->
Real
randIntToReal
x
=
(
toReal
x
+
if
(
x
>=
0
)
0.0
4294967296.0
)
/
4294967295.0
randIntToReal
::
Int
->
Real
randIntToReal
x
=
(
toReal
x
+
if
(
x
>=
0
)
0.0
4294967296.0
)
/
4294967295.0
ggen
{|
String
|}
s
=
[
"hello world!"
,
"Gast"
,
""
:
ggenString
StrLen
4.0
32
126
aStream
]
derive
ggen
(,),
(,,),
(,,,),
(,,,,),
(,,,,,),
(,,,,,,),
(,,,,,,,)
derive
ggen
[],
[!],
[
!],
[!!]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment