PageRenderTime 28ms CodeModel.GetById 15ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/gongshi.lua

https://code.google.com/p/google-pinyin-api/
Lua | 274 lines | 237 code | 27 blank | 10 comment | 70 complexity | cc90d3f49313a5f4d623137e570dbea1 MD5 | raw file
  1-- encoding: UTF-8
  2
  3------------------------------------------------
  4-- ??????????
  5-- ??: 0.1
  6-- ??: Mike
  7-- ????: http://code.google.com/p/google-pinyin-api/
  8--
  9-- ?????GPLv3??
 10------------------------------------------------
 11
 12function liangjiaohe (input)
 13     if input == "a" then
 14             return {
 15            {["suggest"] = "a", ["help"] = "sin(A+B)"},
 16            {["suggest"] = "b", ["help"] = "sin(A-B)"},
 17            {["suggest"] = "c", ["help"] = "cos(A+B)"},
 18            {["suggest"] = "d", ["help"] = "cos(A-B)"},
 19            {["suggest"] = "e", ["help"] = "tan(A+B)"},
 20            {["suggest"] = "f", ["help"] = "tan(A-B)"},
 21            {["suggest"] = "g", ["help"] = "ctg(A+B)"},
 22            {["suggest"] = "h", ["help"] = "ctg(A-B)"},
 23       }
 24   end
 25end
 26
 27
 28function beijiao (input)
 29    if input == "b" then
 30        return {
 31            {["suggest"] = "a", ["help"] = "sin2A"},
 32            {["suggest"] = "b", ["help"] = "cos2A"},
 33            {["suggest"] = "c", ["help"] = "tag2A)"},
 34            {["suggest"] = "d", ["help"] = "ctg2A"},
 35       }
 36    end
 37end
 38
 39
 40function banjiao (input)
 41    if input == "c" then
 42        return {
 43            {["suggest"] = "a", ["help"] = "sin(A/2)"},
 44            {["suggest"] = "b", ["help"] = "cos(A/2)"},
 45            {["suggest"] = "c", ["help"] = "tag(A/2))"},
 46            {["suggest"] = "d", ["help"] = "ctg(A/2)"},
 47       }
 48    end
 49end
 50
 51
 52
 53function hechahuaji (input)
 54    if input == "d" then
 55        return {
 56            {["suggest"] = "a", ["help"] = "sinA+sinB"},
 57            {["suggest"] = "b", ["help"] = "sinA-sinB"},
 58            {["suggest"] = "c", ["help"] = "cosA+cosB"},
 59            {["suggest"] = "d", ["help"] = "cosA-cosB"},
 60       }
 61    end
 62end
 63
 64function jihuahecha (input)
 65    if input == "e" then
 66        return {
 67            {["suggest"] = "a", ["help"] = "sinAcosB"},
 68            {["suggest"] = "b", ["help"] = "cosAsinB"},
 69            {["suggest"] = "c", ["help"] = "sinAsinB"},
 70            {["suggest"] = "d", ["help"] = "cosAcosB"},
 71       }
 72    end
 73end
 74
 75function wanneng (input)
 76    if input == "f" then
 77        return {
 78            {["suggest"] = "a", ["help"] = "sinA"},
 79            {["suggest"] = "b", ["help"] = "cosA"},
 80            {["suggest"] = "c", ["help"] = "tagA"},
 81       }
 82    end
 83end
 84
 85function sanjiao (input)
 86    if #input == 0 then
 87        return {
 88            {["suggest"] = "a", ["help"] = "?????"},
 89            {["suggest"] = "b", ["help"] = "????"},
 90            {["suggest"] = "c", ["help"] = "????"},
 91            {["suggest"] = "d", ["help"] = "????"},
 92            {["suggest"] = "e", ["help"] = "????"},
 93            {["suggest"] = "f", ["help"] = "????"},
 94       }
 95       
 96    elseif input == "a" then
 97        return liangjiaohe(input)
 98    elseif input == "aa" then
 99        return "sin(A+B)=sinAcosB+cosAsinB"
100    elseif input == "ab" then
101        return "sin(A-B)=sinAcosB-sinBcosA"
102    elseif input == "ac" then
103        return "cos(A+B)=cosAcosB-sinAsinB"
104    elseif input == "ad"  then
105        return "cos(A-B)=cosAcosB+sinAsinB"
106    elseif input == "ae"  then
107        return "tan(A+B)=(tanA+tanB)/(1-tanAtanB)"
108    elseif input == "af"  then
109        return "tan(A-B)=(tanA-tanB)/(1+tanAtanB)"
110    elseif input == "ag"  then
111        return "ctg(A+B)=(ctgActgB-1)/(ctgB+ctgA)"
112    elseif input == "ah"  then
113        return "ctg(A-B)=(ctgActgB+1)/(ctgB-ctgA)"      
114        
115    elseif input == "b" then
116        return beijiao(input)
117    elseif input == "ba" then
118        return "sin(A-B)=2sinAcosA"
119    elseif input == "bb" then
120        return "cos2A=(cosA)^2-(sinA)^2=2(cosA)^2-1=1-2(sinA)^2"
121    elseif input == "bc" then
122        return "tag2A=2tanA/[1-(tanA)^2]"
123    elseif input == "bd" then
124        return "ctg2A=[ctgA)^2-1]/2ctgA"
125        
126    elseif input == "c" then
127        return banjiao(input)
128    elseif input == "ca"  then
129        return "sin(A/2)=?[(1-cosA)/2]"
130    elseif input == "cb"  then
131        return "cos(A/2)=?[(1+cosA)/2]"
132    elseif input == "cc"  then
133        return "tan(A/2)=?[(1-cosA)/(1+cosA)]"
134    elseif input == "cd"  then
135        return "ctg(A/2)=?[(1+cosA)/(1-cosA)]"
136        
137     elseif input == "d"  then
138        return hechaohuaji(input)
139     elseif input == "da"  then
140        return "sinA+sinB=2sin[(A+B)/2]cos[(A-B)/2]"
141    elseif input == "db"  then
142        return "sinA-sinB=2cos[(A+B)/2]sin[(A-B)/2]"
143    elseif input == "dc"  then
144        return "cosA+cosB=2cos[(A+B)/2]cos[(A-B)/2]"
145    elseif input == "dd"  then
146        return "cosA-cosB=-2sin[(A+B)/2]sin[(A-B)/2] "
147
148     elseif input == "e"  then
149        return hechaohuaji(input)
150     elseif input == "ea"  then
151        return "sinAcosB=(1/2)[sin(A+B)+sin(A-B)]"
152    elseif input == "eb"  then
153        return "cosAsinB=(1/2)[sin(A+B)-sin(A-B)]"
154    elseif input == "ec"  then
155        return "sinAsinB=-(1/2)[cos(A+B)-cos(A-B)]"
156    elseif input == "ed"  then
157        return "cosAcosB=(1/2)[cos(A+B)+cos(A-B)]"
158
159     elseif input == "f"  then
160        return wanneng(input)
161     elseif input == "fa"  then
162        return "sinA=2tan(A/2)/[1+tan^2(A/2)]"
163    elseif input == "fb"  then
164        return "cosA=[1-tan^2(A/2)]/[1+tan^2(A/2)]"
165    elseif input == "fc"  then
166        return "tanA=2tan(A/2)/[1-tan^2(A/2)]"
167        
168   end
169end
170
171
172
173
174
175function daoshu (input)
176    if #input == 0 then
177        return {
178            {["suggest"] = "a", ["help"] = "C(??)"},
179            {["suggest"] = "b", ["help"] = "x^a"},
180            {["suggest"] = "c", ["help"] = "a^x"},
181            {["suggest"] = "d", ["help"] = "e^x"},
182            {["suggest"] = "e", ["help"] = "loga(x)"},
183            {["suggest"] = "f", ["help"] = "lnx"},
184            {["suggest"] = "g", ["help"] = "sinx"},
185            {["suggest"] = "h", ["help"] = "cosx"},
186            {["suggest"] = "l", ["help"] = "tagx"},
187            {["suggest"] = "j", ["help"] = "ctgx"},
188            {["suggest"] = "k", ["help"] = "secx"},
189            {["suggest"] = "l", ["help"] = "cscx"},
190            {["suggest"] = "m", ["help"] = "arcsinx"},
191            {["suggest"] = "n", ["help"] = "arccosx"},
192            {["suggest"] = "o", ["help"] = "arctagx"},
193            {["suggest"] = "p", ["help"] = "arcctgx"},
194       }
195     elseif input == "a"  then
196        return "(C)'=0"
197     elseif input == "b"  then
198        return "(x^a)'=ax^(a-1)"
199     elseif input == "c"  then
200        return "(a^x)'=a^xˇlna"
201     elseif input == "d"  then
202        return "(e^x)'=e^x"
203     elseif input == "e"  then
204        return "(loga(x))'=1/(xˇlna)"
205     elseif input == "f"  then
206        return "(lnx)'=1/x"
207     elseif input == "g"  then
208        return "(sinx)'=cosx"
209     elseif input == "h"  then
210        return "(cosx)'=-sinx"
211     elseif input == "i"  then
212        return "(tagx)'=(secx)^2"
213     elseif input == "j"  then
214        return "(ctgx)'=-(cscx)^2"
215     elseif input == "k"  then
216        return "(secx)'=secxtagx"
217     elseif input == "l"  then
218        return "(cscx)'=cscxctgx"
219     elseif input == "m"  then
220        return "(arcsinx)'=1/?(1-x^2)"
221     elseif input == "n"  then
222        return "(arccosx)'=-1/?(1-x^2)"
223     elseif input == "o"  then
224        return "(arctagx)'=1/(1+x^2)"
225     elseif input == "p"  then
226        return "(arcctgx)'=-1/(1+x^2)"
227    end
228end
229
230function jifen (input)
231    if #input == 0 then
232        return {
233            {["suggest"] = "a", ["help"] = "?0ˇdx"},
234            {["suggest"] = "b", ["help"] = "?x^aˇdx"},
235            {["suggest"] = "c", ["help"] = "?1/xˇdx"},
236            {["suggest"] = "d", ["help"] = "?a^xˇdx"},
237            {["suggest"] = "e", ["help"] = "?e^xˇdx"},
238            {["suggest"] = "f", ["help"] = "?sinxˇdx"},
239            {["suggest"] = "g", ["help"] = "?cosxˇdx"},
240            {["suggest"] = "h", ["help"] = "?(secx)^2ˇdx"},
241            {["suggest"] = "l", ["help"] = "?(cscx)^2ˇdx"},
242            {["suggest"] = "j", ["help"] = "?1/?(1-x^2)ˇdx"},
243            {["suggest"] = "k", ["help"] = "?1/(1+x^2)ˇdx"},
244       }
245     elseif input == "a"  then
246        return "?0ˇdx=C"
247     elseif input == "b"  then
248        return "?x^aˇdx=1/(a+1)ˇx(a+1)+C (a?-1)"
249     elseif input == "c"  then
250        return "?1/xˇdx=ln|x|+C"
251     elseif input == "d"  then
252        return "?a^xˇdx=1/lnxˇa^x+C (a>0, a?-1)"
253     elseif input == "e"  then
254        return "?e^xˇdx=e^x+C"
255     elseif input == "f"  then
256        return "?sinxˇdx=-cosx+C"
257     elseif input == "g"  then
258        return "?cosxˇdx=sinx+C"
259     elseif input == "h"  then
260        return "?(secx)^2ˇdx=tagx+C"
261     elseif input == "i"  then
262        return "?(cscx)^2ˇdx=-ctgx+C"
263     elseif input == "j"  then
264        return "?1/?(1-x^2)ˇdx=arcsinx+C=-arccosx+C"
265     elseif input == "k"  then
266        return "?1/(1+x^2)ˇdx=arctagx+C=-arcctgx+C"
267    end
268end
269
270------------
271
272ime.register_command("fj", "jifen", "??????")
273ime.register_command("fd", "daoshu", "????????")
274ime.register_command("fs", "sanjiao", "??????")