[m-users.] Conjunction as an operator
Volker Wysk
post at volker-wysk.de
Sun Oct 13 10:29:58 AEDT 2019
Am Samstag, den 12.10.2019, 17:42 -0500 schrieb Julian Fondren:
> On 2019-10-12 17:32, Volker Wysk wrote:
> > Hi!
> >
> > I need a conjunction of two terms, like this:
> >
> > X = (Str \= "" & Str \= ".")
> >
>
> What is X supposed to be, here? What is its type? Whats a possible
> value that it could have?
X should be a boolean value, "yes" or "no". But I've messed up, it
shouldn't be done this way. I wanted to use it as the predicate in a
"filter" call, like:
slice_path_1(PfadL) =
filter( (func(Str::in) = Str \= [] && Str \= ['.']),
split(PfadL)
).
Now I've figured it out:
slice_path_1(PfadL) =
filter( (pred(Str::in) is semidet :-
Str \= [],
Str \= ['.']),
split(PfadL)
).
Old habits from Haskell.
> If you want to fail if Str is either ""
> or ".", you can do that with any of
>
> Str \= "", Str \= "."
>
> not (Str = "" ; Str = ".")
>
> ( if Str = "" ; Str = "." then fail else true )
>
> A,B and A&B only differ operationally: A and B might be executed in
> parallel in the second case.
>
> > This doesn't work. I'm sure I don't understand what's going on.
> > Could
> > somebody please tell me how this is done?
> >
> > Volker
More information about the users
mailing list