Extracting specific data from a list

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












Consider the following list



1., -1, 1.5, -1, 2., 1, 2.5, 1, 3., 1, 3.5, 1, 4., 1, 4.5, 1, 5., 1, 5.5, 1, 6., 1, 6.5, 1, 7., -1, 7.5, -1, 8., -1, 8.5, -1, 9., -1, 9.5, -1, 10., -1


How can I extract only the values after (or before) the second element in the 2-element sublists changes sign, i.e, I would like to obtain as a result



2., 1,7., -1






share|improve this question
























    up vote
    2
    down vote

    favorite












    Consider the following list



    1., -1, 1.5, -1, 2., 1, 2.5, 1, 3., 1, 3.5, 1, 4., 1, 4.5, 1, 5., 1, 5.5, 1, 6., 1, 6.5, 1, 7., -1, 7.5, -1, 8., -1, 8.5, -1, 9., -1, 9.5, -1, 10., -1


    How can I extract only the values after (or before) the second element in the 2-element sublists changes sign, i.e, I would like to obtain as a result



    2., 1,7., -1






    share|improve this question






















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      Consider the following list



      1., -1, 1.5, -1, 2., 1, 2.5, 1, 3., 1, 3.5, 1, 4., 1, 4.5, 1, 5., 1, 5.5, 1, 6., 1, 6.5, 1, 7., -1, 7.5, -1, 8., -1, 8.5, -1, 9., -1, 9.5, -1, 10., -1


      How can I extract only the values after (or before) the second element in the 2-element sublists changes sign, i.e, I would like to obtain as a result



      2., 1,7., -1






      share|improve this question












      Consider the following list



      1., -1, 1.5, -1, 2., 1, 2.5, 1, 3., 1, 3.5, 1, 4., 1, 4.5, 1, 5., 1, 5.5, 1, 6., 1, 6.5, 1, 7., -1, 7.5, -1, 8., -1, 8.5, -1, 9., -1, 9.5, -1, 10., -1


      How can I extract only the values after (or before) the second element in the 2-element sublists changes sign, i.e, I would like to obtain as a result



      2., 1,7., -1








      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 19 at 13:32









      jarhead

      689412




      689412




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          First /@ Rest@SplitBy[list, Sign[#[[2]]] &]



          2., 1, 7., -1




          or



          First /@ Rest@Split[list, Sign[#[[2]]] == Sign[#2[[2]]] &]



          2., 1, 7., -1




          Also



          Pick[list, Developer`ToPackedArray[Unitize[Join[0, 
          Differences @ UnitStep @ Transpose[list][[2]]]]], 1]



          2., 1, 7., -1







          share|improve this answer






















            Your Answer




            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "387"
            ;
            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: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f180242%2fextracting-specific-data-from-a-list%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            5
            down vote



            accepted










            First /@ Rest@SplitBy[list, Sign[#[[2]]] &]



            2., 1, 7., -1




            or



            First /@ Rest@Split[list, Sign[#[[2]]] == Sign[#2[[2]]] &]



            2., 1, 7., -1




            Also



            Pick[list, Developer`ToPackedArray[Unitize[Join[0, 
            Differences @ UnitStep @ Transpose[list][[2]]]]], 1]



            2., 1, 7., -1







            share|improve this answer


























              up vote
              5
              down vote



              accepted










              First /@ Rest@SplitBy[list, Sign[#[[2]]] &]



              2., 1, 7., -1




              or



              First /@ Rest@Split[list, Sign[#[[2]]] == Sign[#2[[2]]] &]



              2., 1, 7., -1




              Also



              Pick[list, Developer`ToPackedArray[Unitize[Join[0, 
              Differences @ UnitStep @ Transpose[list][[2]]]]], 1]



              2., 1, 7., -1







              share|improve this answer
























                up vote
                5
                down vote



                accepted







                up vote
                5
                down vote



                accepted






                First /@ Rest@SplitBy[list, Sign[#[[2]]] &]



                2., 1, 7., -1




                or



                First /@ Rest@Split[list, Sign[#[[2]]] == Sign[#2[[2]]] &]



                2., 1, 7., -1




                Also



                Pick[list, Developer`ToPackedArray[Unitize[Join[0, 
                Differences @ UnitStep @ Transpose[list][[2]]]]], 1]



                2., 1, 7., -1







                share|improve this answer














                First /@ Rest@SplitBy[list, Sign[#[[2]]] &]



                2., 1, 7., -1




                or



                First /@ Rest@Split[list, Sign[#[[2]]] == Sign[#2[[2]]] &]



                2., 1, 7., -1




                Also



                Pick[list, Developer`ToPackedArray[Unitize[Join[0, 
                Differences @ UnitStep @ Transpose[list][[2]]]]], 1]



                2., 1, 7., -1








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Aug 19 at 13:46

























                answered Aug 19 at 13:36









                kglr

                158k8182380




                158k8182380



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f180242%2fextracting-specific-data-from-a-list%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    Confectionery