Article View: comp.lang.prolog
Article #1618Re: (none)
From: tyamamot Taro Yamamoto
Date: Tue, 13 Oct 1992 06:02
Date: Tue, 13 Oct 1992 06:02
31 lines
1294 bytes
1294 bytes
I am learning the language too. But, I got the following idea. I am looking for any more elegant solution... FYI. -Taro Yamamot tyamamot@adobe.com rotate(List, Shift, RotatedList) :- Shift > 0, !, length(List, TotLen), Shift2 is TotLen - Shift, rot(List, Shift2, RotatedList). rotate(List, Shift, RotatedList) :- Shift < 0, !, Shift2 is -Shift, rot(List, Shift2, RotatedList). rot(List, Shift, RotatedList) :- !, append(SubList1, SubList2, List), length(SubList2, Len), Len =:= Shift, !, append(SubList2, SubList1, RotatedList). rot(List, Shift, RotatedList) :- length(List, Len), Shift2 is Len - Shift, !, rot(List, Shift2, RotatedList). Disclaimer: Views and recommendations, express or implied, are my own, and do not reflect the opinion or policy of my employers.
Technical Details
Message-ID:
<tyamamot-131092150955@macj001.tokyo.japan.adobe.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!portal!lll-winken!ames!olivea!hal.com!decwrl!adobe!macj001.tokyo.japan.adobe.com!userReferences:
<9210122012.AA08759@enuxha.eas.asu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!portal!lll-winken!ames!olivea!hal.com!decwrl!adobe!macj001.tokyo.japan.adobe.com!user From: tyamamot (Taro Yamamoto) Newsgroups: comp.lang.prolog Subject: Re: (none) Message-ID: <tyamamot-131092150955@macj001.tokyo.japan.adobe.com> Date: 13 Oct 92 06:02:28 GMT References: <9210122012.AA08759@enuxha.eas.asu.edu> Sender: usenet@adobe.com (USENET NEWS) Followup-To: comp.lang.prolog Organization: Adobe Systems Incorporated Lines: 31