Find CISC prerequisites Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)Fastest way to find all neighbours of a vertex in a graphFind almost-shortest path more efficientlyFind all paths from source to destinationFind unconnected nodes of a graphFind order to install dependenciesNeo4j traversal algorithm to find dense nodesFind the most-connected nodes in a graphAlgorithm to find connected tiles (percolation)Given origin, destination objects, find all the paths from a place to anotherFind the longest connect cells region per color

The code below, is it ill-formed NDR or is it well formed?

An adverb for when you're not exaggerating

How were pictures turned from film to a big picture in a picture frame before digital scanning?

What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?

Are all finite dimensional hilbert spaces isomorphic to spaces with Euclidean norms?

What is the difference between globalisation and imperialism?

How come Sam didn't become Lord of Horn Hill?

Chinese Seal on silk painting - what does it mean?

Performance gap between vector<bool> and array

Dating a Former Employee

Why do we need to use the builder design pattern when we can do the same thing with setters?

Why is my ESD wriststrap failing with nitrile gloves on?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

Generate an RGB colour grid

Why is Nikon 1.4g better when Nikon 1.8g is sharper?

Why does the remaining Rebel fleet at the end of Rogue One seem dramatically larger than the one in A New Hope?

Question about debouncing - delay of state change

How does the math work when buying airline miles?

Effects on objects due to a brief relocation of massive amounts of mass

Sum letters are not two different

What's the meaning of "fortified infraction restraint"?

Drawing without replacement: why is the order of draw irrelevant?

Selecting user stories during sprint planning

NumericArray versus PackedArray in MMA12



Find CISC prerequisites



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)Fastest way to find all neighbours of a vertex in a graphFind almost-shortest path more efficientlyFind all paths from source to destinationFind unconnected nodes of a graphFind order to install dependenciesNeo4j traversal algorithm to find dense nodesFind the most-connected nodes in a graphAlgorithm to find connected tiles (percolation)Given origin, destination objects, find all the paths from a place to anotherFind the longest connect cells region per color



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0












$begingroup$


Below I have some code written in prolog as a brief example. The goal of the program is to take a Computer and Information Science (CISC) course number and return any CISC prerequisites (prereqs).



I would like to know if this code followed common practices in prolog.



%CISC Courses
cisc(100).
cisc(101).
cisc(103).
cisc(106).
cisc(120).
cisc(160).
cisc(201).
cisc(211).
cisc(225).
cisc(233).
cisc(298).
cisc(300).
cisc(301).
cisc(311).
cisc(320).
cisc(330).
cisc(333).
cisc(340).
cisc(349).
cisc(365).
cisc(370).
cisc(380).
cisc(390).
cisc(397).
cisc(399).
cisc(400).
cisc(431).
cisc(432).
cisc(433).
cisc(440).
cisc(444).
cisc(460).
cisc(491).
cisc(498).
cisc(499).

Define Prereqs
prereqs(160,120).
prereqs(211,120).
prereqs(225,120).
prereqs(300,120).
prereqs(233,160).

prereqs(301,211).
prereqs(301,233).
prereqs(311,160).
prereqs(311,225).
prereqs(320,211).

prereqs(320,233).
prereqs(330,211).
prereqs(333,233).
prereqs(340,233).
prereqs(349,233).

prereqs(370,333).
prereqs(390,120).
prereqs(397,225).
prereqs(397,301).
prereqs(399,233).

prereqs(400,233).
prereqs(400,301).
prereqs(431,233).
prereqs(431,399).
prereqs(432,233).

prereqs(433,301).
prereqs(433,399).
prereqs(440,370).
prereqs(444,433).
prereqs(460,225).

prereqs(460,233).
prereqs(491,225).
prereqs(491,301).
prereqs(498,298).

%Return prereqs to a given class with prereqs of prereqs
prereq(X,Y) :- prereqs(X,Y),format("CISC ~w is a prereq of CISC ~w~n",[Y,X]).

prereq(X,Y) :- prereqs(X,Z),
prereq(Z, Y).









share|improve this question











$endgroup$




bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • $begingroup$
    Looks like you need loops to setup.
    $endgroup$
    – πάντα ῥεῖ
    Nov 16 '18 at 5:30










  • $begingroup$
    There is a recursive call at the end. It's hard to tell because of the naming structure i've used.
    $endgroup$
    – DanSchneiderNA
    Nov 16 '18 at 5:45

















0












$begingroup$


Below I have some code written in prolog as a brief example. The goal of the program is to take a Computer and Information Science (CISC) course number and return any CISC prerequisites (prereqs).



I would like to know if this code followed common practices in prolog.



%CISC Courses
cisc(100).
cisc(101).
cisc(103).
cisc(106).
cisc(120).
cisc(160).
cisc(201).
cisc(211).
cisc(225).
cisc(233).
cisc(298).
cisc(300).
cisc(301).
cisc(311).
cisc(320).
cisc(330).
cisc(333).
cisc(340).
cisc(349).
cisc(365).
cisc(370).
cisc(380).
cisc(390).
cisc(397).
cisc(399).
cisc(400).
cisc(431).
cisc(432).
cisc(433).
cisc(440).
cisc(444).
cisc(460).
cisc(491).
cisc(498).
cisc(499).

Define Prereqs
prereqs(160,120).
prereqs(211,120).
prereqs(225,120).
prereqs(300,120).
prereqs(233,160).

prereqs(301,211).
prereqs(301,233).
prereqs(311,160).
prereqs(311,225).
prereqs(320,211).

prereqs(320,233).
prereqs(330,211).
prereqs(333,233).
prereqs(340,233).
prereqs(349,233).

prereqs(370,333).
prereqs(390,120).
prereqs(397,225).
prereqs(397,301).
prereqs(399,233).

prereqs(400,233).
prereqs(400,301).
prereqs(431,233).
prereqs(431,399).
prereqs(432,233).

prereqs(433,301).
prereqs(433,399).
prereqs(440,370).
prereqs(444,433).
prereqs(460,225).

prereqs(460,233).
prereqs(491,225).
prereqs(491,301).
prereqs(498,298).

%Return prereqs to a given class with prereqs of prereqs
prereq(X,Y) :- prereqs(X,Y),format("CISC ~w is a prereq of CISC ~w~n",[Y,X]).

prereq(X,Y) :- prereqs(X,Z),
prereq(Z, Y).









share|improve this question











$endgroup$




bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • $begingroup$
    Looks like you need loops to setup.
    $endgroup$
    – πάντα ῥεῖ
    Nov 16 '18 at 5:30










  • $begingroup$
    There is a recursive call at the end. It's hard to tell because of the naming structure i've used.
    $endgroup$
    – DanSchneiderNA
    Nov 16 '18 at 5:45













0












0








0





$begingroup$


Below I have some code written in prolog as a brief example. The goal of the program is to take a Computer and Information Science (CISC) course number and return any CISC prerequisites (prereqs).



I would like to know if this code followed common practices in prolog.



%CISC Courses
cisc(100).
cisc(101).
cisc(103).
cisc(106).
cisc(120).
cisc(160).
cisc(201).
cisc(211).
cisc(225).
cisc(233).
cisc(298).
cisc(300).
cisc(301).
cisc(311).
cisc(320).
cisc(330).
cisc(333).
cisc(340).
cisc(349).
cisc(365).
cisc(370).
cisc(380).
cisc(390).
cisc(397).
cisc(399).
cisc(400).
cisc(431).
cisc(432).
cisc(433).
cisc(440).
cisc(444).
cisc(460).
cisc(491).
cisc(498).
cisc(499).

Define Prereqs
prereqs(160,120).
prereqs(211,120).
prereqs(225,120).
prereqs(300,120).
prereqs(233,160).

prereqs(301,211).
prereqs(301,233).
prereqs(311,160).
prereqs(311,225).
prereqs(320,211).

prereqs(320,233).
prereqs(330,211).
prereqs(333,233).
prereqs(340,233).
prereqs(349,233).

prereqs(370,333).
prereqs(390,120).
prereqs(397,225).
prereqs(397,301).
prereqs(399,233).

prereqs(400,233).
prereqs(400,301).
prereqs(431,233).
prereqs(431,399).
prereqs(432,233).

prereqs(433,301).
prereqs(433,399).
prereqs(440,370).
prereqs(444,433).
prereqs(460,225).

prereqs(460,233).
prereqs(491,225).
prereqs(491,301).
prereqs(498,298).

%Return prereqs to a given class with prereqs of prereqs
prereq(X,Y) :- prereqs(X,Y),format("CISC ~w is a prereq of CISC ~w~n",[Y,X]).

prereq(X,Y) :- prereqs(X,Z),
prereq(Z, Y).









share|improve this question











$endgroup$




Below I have some code written in prolog as a brief example. The goal of the program is to take a Computer and Information Science (CISC) course number and return any CISC prerequisites (prereqs).



I would like to know if this code followed common practices in prolog.



%CISC Courses
cisc(100).
cisc(101).
cisc(103).
cisc(106).
cisc(120).
cisc(160).
cisc(201).
cisc(211).
cisc(225).
cisc(233).
cisc(298).
cisc(300).
cisc(301).
cisc(311).
cisc(320).
cisc(330).
cisc(333).
cisc(340).
cisc(349).
cisc(365).
cisc(370).
cisc(380).
cisc(390).
cisc(397).
cisc(399).
cisc(400).
cisc(431).
cisc(432).
cisc(433).
cisc(440).
cisc(444).
cisc(460).
cisc(491).
cisc(498).
cisc(499).

Define Prereqs
prereqs(160,120).
prereqs(211,120).
prereqs(225,120).
prereqs(300,120).
prereqs(233,160).

prereqs(301,211).
prereqs(301,233).
prereqs(311,160).
prereqs(311,225).
prereqs(320,211).

prereqs(320,233).
prereqs(330,211).
prereqs(333,233).
prereqs(340,233).
prereqs(349,233).

prereqs(370,333).
prereqs(390,120).
prereqs(397,225).
prereqs(397,301).
prereqs(399,233).

prereqs(400,233).
prereqs(400,301).
prereqs(431,233).
prereqs(431,399).
prereqs(432,233).

prereqs(433,301).
prereqs(433,399).
prereqs(440,370).
prereqs(444,433).
prereqs(460,225).

prereqs(460,233).
prereqs(491,225).
prereqs(491,301).
prereqs(498,298).

%Return prereqs to a given class with prereqs of prereqs
prereq(X,Y) :- prereqs(X,Y),format("CISC ~w is a prereq of CISC ~w~n",[Y,X]).

prereq(X,Y) :- prereqs(X,Z),
prereq(Z, Y).






graph prolog






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 20:18









200_success

131k17157422




131k17157422










asked Nov 16 '18 at 5:24









DanSchneiderNADanSchneiderNA

23729




23729





bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.













  • $begingroup$
    Looks like you need loops to setup.
    $endgroup$
    – πάντα ῥεῖ
    Nov 16 '18 at 5:30










  • $begingroup$
    There is a recursive call at the end. It's hard to tell because of the naming structure i've used.
    $endgroup$
    – DanSchneiderNA
    Nov 16 '18 at 5:45
















  • $begingroup$
    Looks like you need loops to setup.
    $endgroup$
    – πάντα ῥεῖ
    Nov 16 '18 at 5:30










  • $begingroup$
    There is a recursive call at the end. It's hard to tell because of the naming structure i've used.
    $endgroup$
    – DanSchneiderNA
    Nov 16 '18 at 5:45















$begingroup$
Looks like you need loops to setup.
$endgroup$
– πάντα ῥεῖ
Nov 16 '18 at 5:30




$begingroup$
Looks like you need loops to setup.
$endgroup$
– πάντα ῥεῖ
Nov 16 '18 at 5:30












$begingroup$
There is a recursive call at the end. It's hard to tell because of the naming structure i've used.
$endgroup$
– DanSchneiderNA
Nov 16 '18 at 5:45




$begingroup$
There is a recursive call at the end. It's hard to tell because of the naming structure i've used.
$endgroup$
– DanSchneiderNA
Nov 16 '18 at 5:45










1 Answer
1






active

oldest

votes


















0












$begingroup$

In my opinion, your code would benefit considerably from a better naming convention.



In Prolog, a good predicate name makes clear what each argument denotes.



For example, when I see:




prereqs(460, 233).


then I have no idea what the arguments are. I see it is about prerequisites, but in which direction? Is 460 a prerequisite of 233, or is it the other way around? Also, why is this called "prereqs" although each clause only denotes a single prerequisite?



A much more descriptive name for this predicate would be (for example!):




prerequisite_of_course(460, 230).


because this makes clear what is the prerequisite of what. Another very good, descriptive name would be for example:




course_prerequisite(230, 460).


You will find that, if you use more descriptive names, then emitting output yourself will become unnecessary: The predicate name alone will make the situation perfectly clear. Let the toplevel do the printing for you!



The variable names in:




prereq(X, Y) :-
prereqs(X, Z),
prereq(Z, Y).


could also be improved considerably by choosing more descriptive names or abbreviations, such as Req, Course etc. For transitive relations between courses, you can for example use:



Course0 &rightarrow; Course1 &rightarrow; ... &rightarrow; Course






share|improve this answer









$endgroup$













    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: "196"
    ;
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f207778%2ffind-cisc-prerequisites%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









    0












    $begingroup$

    In my opinion, your code would benefit considerably from a better naming convention.



    In Prolog, a good predicate name makes clear what each argument denotes.



    For example, when I see:




    prereqs(460, 233).


    then I have no idea what the arguments are. I see it is about prerequisites, but in which direction? Is 460 a prerequisite of 233, or is it the other way around? Also, why is this called "prereqs" although each clause only denotes a single prerequisite?



    A much more descriptive name for this predicate would be (for example!):




    prerequisite_of_course(460, 230).


    because this makes clear what is the prerequisite of what. Another very good, descriptive name would be for example:




    course_prerequisite(230, 460).


    You will find that, if you use more descriptive names, then emitting output yourself will become unnecessary: The predicate name alone will make the situation perfectly clear. Let the toplevel do the printing for you!



    The variable names in:




    prereq(X, Y) :-
    prereqs(X, Z),
    prereq(Z, Y).


    could also be improved considerably by choosing more descriptive names or abbreviations, such as Req, Course etc. For transitive relations between courses, you can for example use:



    Course0 &rightarrow; Course1 &rightarrow; ... &rightarrow; Course






    share|improve this answer









    $endgroup$

















      0












      $begingroup$

      In my opinion, your code would benefit considerably from a better naming convention.



      In Prolog, a good predicate name makes clear what each argument denotes.



      For example, when I see:




      prereqs(460, 233).


      then I have no idea what the arguments are. I see it is about prerequisites, but in which direction? Is 460 a prerequisite of 233, or is it the other way around? Also, why is this called "prereqs" although each clause only denotes a single prerequisite?



      A much more descriptive name for this predicate would be (for example!):




      prerequisite_of_course(460, 230).


      because this makes clear what is the prerequisite of what. Another very good, descriptive name would be for example:




      course_prerequisite(230, 460).


      You will find that, if you use more descriptive names, then emitting output yourself will become unnecessary: The predicate name alone will make the situation perfectly clear. Let the toplevel do the printing for you!



      The variable names in:




      prereq(X, Y) :-
      prereqs(X, Z),
      prereq(Z, Y).


      could also be improved considerably by choosing more descriptive names or abbreviations, such as Req, Course etc. For transitive relations between courses, you can for example use:



      Course0 &rightarrow; Course1 &rightarrow; ... &rightarrow; Course






      share|improve this answer









      $endgroup$















        0












        0








        0





        $begingroup$

        In my opinion, your code would benefit considerably from a better naming convention.



        In Prolog, a good predicate name makes clear what each argument denotes.



        For example, when I see:




        prereqs(460, 233).


        then I have no idea what the arguments are. I see it is about prerequisites, but in which direction? Is 460 a prerequisite of 233, or is it the other way around? Also, why is this called "prereqs" although each clause only denotes a single prerequisite?



        A much more descriptive name for this predicate would be (for example!):




        prerequisite_of_course(460, 230).


        because this makes clear what is the prerequisite of what. Another very good, descriptive name would be for example:




        course_prerequisite(230, 460).


        You will find that, if you use more descriptive names, then emitting output yourself will become unnecessary: The predicate name alone will make the situation perfectly clear. Let the toplevel do the printing for you!



        The variable names in:




        prereq(X, Y) :-
        prereqs(X, Z),
        prereq(Z, Y).


        could also be improved considerably by choosing more descriptive names or abbreviations, such as Req, Course etc. For transitive relations between courses, you can for example use:



        Course0 &rightarrow; Course1 &rightarrow; ... &rightarrow; Course






        share|improve this answer









        $endgroup$



        In my opinion, your code would benefit considerably from a better naming convention.



        In Prolog, a good predicate name makes clear what each argument denotes.



        For example, when I see:




        prereqs(460, 233).


        then I have no idea what the arguments are. I see it is about prerequisites, but in which direction? Is 460 a prerequisite of 233, or is it the other way around? Also, why is this called "prereqs" although each clause only denotes a single prerequisite?



        A much more descriptive name for this predicate would be (for example!):




        prerequisite_of_course(460, 230).


        because this makes clear what is the prerequisite of what. Another very good, descriptive name would be for example:




        course_prerequisite(230, 460).


        You will find that, if you use more descriptive names, then emitting output yourself will become unnecessary: The predicate name alone will make the situation perfectly clear. Let the toplevel do the printing for you!



        The variable names in:




        prereq(X, Y) :-
        prereqs(X, Z),
        prereq(Z, Y).


        could also be improved considerably by choosing more descriptive names or abbreviations, such as Req, Course etc. For transitive relations between courses, you can for example use:



        Course0 &rightarrow; Course1 &rightarrow; ... &rightarrow; Course







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 19:59









        matmat

        65137




        65137



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Code Review Stack Exchange!


            • 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.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f207778%2ffind-cisc-prerequisites%23new-answer', 'question_page');

            );

            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







            Popular posts from this blog

            名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

            香港授勳及嘉獎制度 目录 勳章及獎狀類別 嘉獎等級 授勳及嘉獎提名 統計數字 多次獲頒勳章或獎狀的人士 爭議 褫奪機制 参考文献 外部連結 参见 导航菜单統計數字一九九七年七月二日(星期三)香港特別行政區的授勳制度六七暴動領袖獲大紫荊勳章 董建華被斥為肯定殺人放火董建華授勳楊光 議員窮追猛打蘋論:顛倒是非黑白的大紫荊董讚楊光有貢獻避談暴動董拒答授勳楊光原因撤除勳銜撤除勳銜撤除勳銜特首掌「搣柴」生殺權行為失當罪 隨時「搣柴」失長糧政府刊憲 許仕仁郭炳江遭「搣柴」去年中終極上訴失敗 許仕仁郭炳江撤勳章太平紳士猛料阿Sir講古—— 「搣柴」有故一九九八年授勳名單一九九九年授勳名單二○○三年授勳名單二○○八年授勳名單二○○七年授勳名單政府總部禮賓處 - 授勳及嘉獎香港特別行政區勳章綬帶一覽(PDF)(非官方)

            Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar