FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log inLog in 


Difference between "in" and isMember/2 ?

Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog
View previous topic :: View next topic  
Author Message
Harrison Pratt



Des Moines, Iowa USA
Joined: 05 Nov 2000
Posts: 312

PostPosted: 2 Aug 2017 17:07    Post subject: Difference between "in" and isMember/2 ? Reply with quote

I recently ran across "in" as a test for an item being a list member

Item in SomeItemList

and wondered if this is in any way different (other than syntax) from

list::isMember( Item, SomeItemList )

I couldn't find documentation on "in".
Back to top
View user's profile Send private message
Gukalov



Orthez, France
Joined: 05 Oct 2011
Posts: 22

PostPosted: 3 Aug 2017 16:11    Post subject: Reply with quote

Hi.
"in" can be used instead of list::getMember_nd/1 and etc...

implement main
    open core, console

clauses
    run() :-
        List = [ 1, 2, 3, 4, 5 ],

        foreach X in List do
            write(X, " ")
        end foreach,

        nl, nl,

        foreach Y in setM_redBlack::new(List) do
            write(Y, " ")
        end foreach,

        write("\n...........................\n"),
        _ = readChar().

end implement main

goal
    console::run(main::run).


_________________
aagukalov@gmail.com
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3124

PostPosted: 3 Aug 2017 18:54    Post subject: Reply with quote

in is documented here: Language_Reference/Terms#in.
_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Harrison Pratt



Des Moines, Iowa USA
Joined: 05 Nov 2000
Posts: 312

PostPosted: 4 Aug 2017 11:57    Post subject: Reply with quote

Thanks, Thomas and Gukalov!
Looking at "in" in the debugger I see that it is part of the VIP runtime and can be used without having to bring the list class into a project ... which is probably the most trivial of considerations in real life. (It's hard to search for a word (in) that is used so commonly in many non-code ways. Wink )
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3124

PostPosted: 6 Aug 2017 19:10    Post subject: Reply with quote

Yes, 'in' occurs too often to search for it.

The 'in' operators are properties (specified as attibutes) of domains and interfaces. So the in operators of a domain/interface are visible when the domain is visible.

The list domain is built-in and always visible, subsequently its in operators are also always visibl.

_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum