原创 haskell代碼片段
-- 一個經典的菲波納契數列的函數定義,求每一個位置上的數值fib 1 = 1fib 2 = 1fib n = fib(n-1) + fib(n-2)-- 產生一個無限長的fib數列fib_l n = fib n : fib_l(n+1)
原创 隱藏Windows命令提示窗Hiding the console on windows
用ghc編譯時加上:-optl-mwindows 參見: http://comments.gmane.org/gmane.comp.lang.haskell.gtk2hs/1984
原创 ghc-6.10.3和gtk2hs-0.10.1-win32安裝包
http://sourceforge.net/projects/gtk2hs/ ghc-6.10.3-i386-windows.exe gtk2hs-0.10.1-win32-installer.exe
原创 揹包問題的haskell解法
-- file: knapsack1.hs maxVal [] [] _ = 0 maxVal (w:ws) (v:vs) aW = if w > aW then without_it else max without
原创 WIN7下的會聲會影出現了兼容性的問題
WIN7下的會聲會影X2出現了兼容性的問題,具體表現是在刻錄光盤的時侯按鈕被擋住了,解決的辦法是按ALT+N跳過,然後刻錄的介面就會出來了 http://bbs.pcbeta.com/viewthread-542676-1-1.htm
原创 Android Studio不能用adb
運行android studio,提示adb找不到設備 在命令行下進入C:\Users\Administrator\AppData\Local\Android\Sdk\platform-tools,運行adb.exe,提示0xc00000
原创 揹包問題knapsack與動態編程
def maxVal(w, v, i, aW): global numCalls numCalls += 1 print numCalls, 'maxVal called with: ', i, aW if i =
原创 haskell如何處理中文字符?
參見:http://www.btsmth.com/show_snapshot.php?en_name=FuncProgram&gid=20701 要用到ghc的一些特性ImplicitParams。module Main( main
原创 分解質因數
-- 分解質因數-- file: pfactors.hs primes = sieve [2..] where sieve (x:xs) = x : sieve (filter (/y ->y `rem` x /= 0) xs)
原创 Fibonacci數列
module Main where import System.Environment fib :: Int -> Intfib 1 = 1fib 2 = 1fib x = fib(x-2) + fib(x-1) fib' 1 =
原创 歸併排序
def mergesort(L): print L if len(L) < 2: return L[:] else: middle = len(L) / 2 left = mer
原创 牛頓/拉復生法求平方根
def squareRootNR(x, epsilon): assert x >= 0 assert epsilon >= 0 x = float(x) guess = x/2.0## guess = 0.0
原创 篩法求素數
def prime(n, ps): for i in ps: if n % i == 0: return ps ps.append(n) return ps def primes(
原创 等比級數(geometric progression) 和等差數列
--等比級數 geometric progressiongp a q = a : gp (a*q) q--gp a q = map (/x -> a*q^x) [0..] ap a d = a : ap (a+d) d -- ap a
原创 《培生小學英語分級閱讀80篇 五年級》勘誤表
《培生小學英語分級閱讀80篇 五年級》勘誤表 培生小學英語分級閱讀80篇 五年級 於景霞 主編 北京:外文出版社,2018.7 ISBN 978-7-119-11585-6 http://www.flp.com.cn 頁碼