how to check if a path is well formed with FsCheck in FSharp
up vote
1
down vote
favorite
I'm struggling getting an answer to this:
Define a function functionWF and functionPath that takes an FsTree and returns a boolean that check whether the given tree is well-formed as a filesystem and whether the path (represented as a list of strings) is well-formed.
A well-formed filesystem cannot have identical paths leading to different nodes in the tree.
A well-formed path cannot contain nodes with empty names.
bellow a the type FsTree = Node of (string * FsTree) list
and bellow is an example of a FsTree :
fsT = [Node ("f1", [Node ("f2", )]); [Node ("f3", )]]
f# nuget-package fscheck
add a comment |
up vote
1
down vote
favorite
I'm struggling getting an answer to this:
Define a function functionWF and functionPath that takes an FsTree and returns a boolean that check whether the given tree is well-formed as a filesystem and whether the path (represented as a list of strings) is well-formed.
A well-formed filesystem cannot have identical paths leading to different nodes in the tree.
A well-formed path cannot contain nodes with empty names.
bellow a the type FsTree = Node of (string * FsTree) list
and bellow is an example of a FsTree :
fsT = [Node ("f1", [Node ("f2", )]); [Node ("f3", )]]
f# nuget-package fscheck
5
Hi there, welcome to Stack Overflow :) You've defined your problem well, which is great :) could you please provide the code which you have so far, along with a description or example of 1.) what it's currently doing 2.) what you want it to be doing, and 3.) what you've tried to fix it, so far
– MyStackRunnethOver
Nov 22 at 0:22
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm struggling getting an answer to this:
Define a function functionWF and functionPath that takes an FsTree and returns a boolean that check whether the given tree is well-formed as a filesystem and whether the path (represented as a list of strings) is well-formed.
A well-formed filesystem cannot have identical paths leading to different nodes in the tree.
A well-formed path cannot contain nodes with empty names.
bellow a the type FsTree = Node of (string * FsTree) list
and bellow is an example of a FsTree :
fsT = [Node ("f1", [Node ("f2", )]); [Node ("f3", )]]
f# nuget-package fscheck
I'm struggling getting an answer to this:
Define a function functionWF and functionPath that takes an FsTree and returns a boolean that check whether the given tree is well-formed as a filesystem and whether the path (represented as a list of strings) is well-formed.
A well-formed filesystem cannot have identical paths leading to different nodes in the tree.
A well-formed path cannot contain nodes with empty names.
bellow a the type FsTree = Node of (string * FsTree) list
and bellow is an example of a FsTree :
fsT = [Node ("f1", [Node ("f2", )]); [Node ("f3", )]]
f# nuget-package fscheck
f# nuget-package fscheck
edited Nov 22 at 2:11
asked Nov 21 at 23:43
zaire crypto
62
62
5
Hi there, welcome to Stack Overflow :) You've defined your problem well, which is great :) could you please provide the code which you have so far, along with a description or example of 1.) what it's currently doing 2.) what you want it to be doing, and 3.) what you've tried to fix it, so far
– MyStackRunnethOver
Nov 22 at 0:22
add a comment |
5
Hi there, welcome to Stack Overflow :) You've defined your problem well, which is great :) could you please provide the code which you have so far, along with a description or example of 1.) what it's currently doing 2.) what you want it to be doing, and 3.) what you've tried to fix it, so far
– MyStackRunnethOver
Nov 22 at 0:22
5
5
Hi there, welcome to Stack Overflow :) You've defined your problem well, which is great :) could you please provide the code which you have so far, along with a description or example of 1.) what it's currently doing 2.) what you want it to be doing, and 3.) what you've tried to fix it, so far
– MyStackRunnethOver
Nov 22 at 0:22
Hi there, welcome to Stack Overflow :) You've defined your problem well, which is great :) could you please provide the code which you have so far, along with a description or example of 1.) what it's currently doing 2.) what you want it to be doing, and 3.) what you've tried to fix it, so far
– MyStackRunnethOver
Nov 22 at 0:22
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
A Node is ill-formed if it contains more than one element with the same name, or if that is the case for any of the subtrees that it contains. Specifically, Node is well-formed. Those concepts can be the cases the recursive function functionWF:
let rec functionWF (tree : FsTree) : bool =
match tree with
| Node -> true
| Node list ->
let strings = List.map fst list
let trees = List.map snd list
let namesOk = allElementsUnique strings
let subtreeOk state tree = state && (functionWF tree)
List.fold subtreeOk namesOk trees
where allElementsUnique is a function that ensures that there are no duplicate elements in a list.
I don't understand what you mean that functionPath should do.
PS. Your example of an FsTree is not valid, it should have Node outside of the list:
let fsT = Node [("f1", Node [("f2", Node )]); ("f3", Node )]
New contributor
jaderberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421993%2fhow-to-check-if-a-path-is-well-formed-with-fscheck-in-fsharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
A Node is ill-formed if it contains more than one element with the same name, or if that is the case for any of the subtrees that it contains. Specifically, Node is well-formed. Those concepts can be the cases the recursive function functionWF:
let rec functionWF (tree : FsTree) : bool =
match tree with
| Node -> true
| Node list ->
let strings = List.map fst list
let trees = List.map snd list
let namesOk = allElementsUnique strings
let subtreeOk state tree = state && (functionWF tree)
List.fold subtreeOk namesOk trees
where allElementsUnique is a function that ensures that there are no duplicate elements in a list.
I don't understand what you mean that functionPath should do.
PS. Your example of an FsTree is not valid, it should have Node outside of the list:
let fsT = Node [("f1", Node [("f2", Node )]); ("f3", Node )]
New contributor
jaderberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
1
down vote
A Node is ill-formed if it contains more than one element with the same name, or if that is the case for any of the subtrees that it contains. Specifically, Node is well-formed. Those concepts can be the cases the recursive function functionWF:
let rec functionWF (tree : FsTree) : bool =
match tree with
| Node -> true
| Node list ->
let strings = List.map fst list
let trees = List.map snd list
let namesOk = allElementsUnique strings
let subtreeOk state tree = state && (functionWF tree)
List.fold subtreeOk namesOk trees
where allElementsUnique is a function that ensures that there are no duplicate elements in a list.
I don't understand what you mean that functionPath should do.
PS. Your example of an FsTree is not valid, it should have Node outside of the list:
let fsT = Node [("f1", Node [("f2", Node )]); ("f3", Node )]
New contributor
jaderberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
1
down vote
up vote
1
down vote
A Node is ill-formed if it contains more than one element with the same name, or if that is the case for any of the subtrees that it contains. Specifically, Node is well-formed. Those concepts can be the cases the recursive function functionWF:
let rec functionWF (tree : FsTree) : bool =
match tree with
| Node -> true
| Node list ->
let strings = List.map fst list
let trees = List.map snd list
let namesOk = allElementsUnique strings
let subtreeOk state tree = state && (functionWF tree)
List.fold subtreeOk namesOk trees
where allElementsUnique is a function that ensures that there are no duplicate elements in a list.
I don't understand what you mean that functionPath should do.
PS. Your example of an FsTree is not valid, it should have Node outside of the list:
let fsT = Node [("f1", Node [("f2", Node )]); ("f3", Node )]
New contributor
jaderberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
A Node is ill-formed if it contains more than one element with the same name, or if that is the case for any of the subtrees that it contains. Specifically, Node is well-formed. Those concepts can be the cases the recursive function functionWF:
let rec functionWF (tree : FsTree) : bool =
match tree with
| Node -> true
| Node list ->
let strings = List.map fst list
let trees = List.map snd list
let namesOk = allElementsUnique strings
let subtreeOk state tree = state && (functionWF tree)
List.fold subtreeOk namesOk trees
where allElementsUnique is a function that ensures that there are no duplicate elements in a list.
I don't understand what you mean that functionPath should do.
PS. Your example of an FsTree is not valid, it should have Node outside of the list:
let fsT = Node [("f1", Node [("f2", Node )]); ("f3", Node )]
New contributor
jaderberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
jaderberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 5 hours ago
jaderberg
1111
1111
New contributor
jaderberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
jaderberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
jaderberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421993%2fhow-to-check-if-a-path-is-well-formed-with-fscheck-in-fsharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
Hi there, welcome to Stack Overflow :) You've defined your problem well, which is great :) could you please provide the code which you have so far, along with a description or example of 1.) what it's currently doing 2.) what you want it to be doing, and 3.) what you've tried to fix it, so far
– MyStackRunnethOver
Nov 22 at 0:22