• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-341  評(píng)論-2670  文章-0  trackbacks-0
                有了Expected語(yǔ)法之后總是要實(shí)驗(yàn)一下的。現(xiàn)在給出一個(gè)非完整函數(shù)eq的聲明,并用一個(gè)列表查找函數(shù)使用eq。已知代碼如下:
             1 module main
             2 import system
             3 import sysutils
             4 import list
             5 
             6 func eq T :: T -> T -> bool expected
             7 
             8 def exists e xs =
             9     select xs of
            10         case list x tail : if(eq e x) true (exists e tail)
            11         case empty : false
            12     end
            13 
            14 def eq a b = iequ a b
            15 
            16 def eq a b = fequ a b
            17 
            18 def main score = if (flt score 60.0"fail" "pass"
            19 
            20 def ints = list 1 (list 2 (list 3 empty))
            21 def floats = list 1.0 (list 2.0 (list 3.0 empty))
            22 def chars = "vczh"
            23 
            24 def main2 = exists 0 ints
            25 def main3 = exists 0.0 floats
            26 def main4 = exists 'a' chars

                注意最后一行。由于exists在這里接受字符,但是不存在接受字符的eq,因此輸出錯(cuò)誤:
            1 生成符號(hào)表時(shí)發(fā)生錯(cuò)誤
            2 錯(cuò)誤[1]    模塊:main    行號(hào):10
            3 信息:符號(hào)"eq"無(wú)法匹配到函數(shù),類(lèi)型:(system.char -> (system.char -> system.bool))。

                如果我們把最后一行去掉,則會(huì)產(chǎn)生正確的結(jié)果。注意exists的兩個(gè)實(shí)例所對(duì)應(yīng)的eq是不同的:
              1 【Code Unit main】
              2     module main::main
              3     import list
              4     import system
              5     import sysutils
              6     func eq T :: (<T> -> (<T> -> system.bool)) expected
              7     func chars :: (system.list system.char) codefrom 7
              8     func eq :: (system.int -> (system.int -> system.bool)) codefrom 2
              9     func eq :: (system.float -> (system.float -> system.bool)) codefrom 3
             10     func exists T1 :: (<T1> -> ((system.list <T1>-> system.bool)) codefrom 1
             11     func floats :: (system.list system.float) codefrom 6
             12     func ints :: (system.list system.int) codefrom 5
             13     func main :: (system.float -> (system.list system.char)) codefrom 4
             14     func main2 :: system.bool codefrom 8
             15     func main3 :: system.bool codefrom 9
             16 
             17 【Assembly Unit main】
             18 
             19     [Information]
             20         Name             : main
             21         Function Count   : 9
             22         Slot Count       : 10
             23 
             24     [Function]
             25         Function Name    : chars
             26         Unique Name      : main::chars::#7
             27         Owner Unit       : main
             28         Level            : 0
             29         External Command : 
             30         Instance         : main::chars::#7::(system.list system.char)
             31 
             32     [Function]
             33         Function Name    : eq
             34         Unique Name      : main::eq::#2
             35         Owner Unit       : main
             36         Level            : 0
             37         External Command : 
             38         Instance         : main::eq::#2::(system.int -> (system.int -> system.bool))
             39 
             40     [Function]
             41         Function Name    : eq
             42         Unique Name      : main::eq::#3
             43         Owner Unit       : main
             44         Level            : 0
             45         External Command : 
             46         Instance         : main::eq::#3::(system.float -> (system.float -> system.bool))
             47 
             48     [Function]
             49         Function Name    : exists
             50         Unique Name      : main::exists::#1
             51         Owner Unit       : main
             52         Level            : 0
             53         External Command : 
             54         Instance         : <NULL>
             55 
             56     [Function]
             57         Function Name    : floats
             58         Unique Name      : main::floats::#6
             59         Owner Unit       : main
             60         Level            : 0
             61         External Command : 
             62         Instance         : main::floats::#6::(system.list system.float)
             63 
             64     [Function]
             65         Function Name    : ints
             66         Unique Name      : main::ints::#5
             67         Owner Unit       : main
             68         Level            : 0
             69         External Command : 
             70         Instance         : main::ints::#5::(system.list system.int)
             71 
             72     [Function]
             73         Function Name    : main2
             74         Unique Name      : main::main2::#8
             75         Owner Unit       : main
             76         Level            : 0
             77         External Command : 
             78         Instance         : main::main2::#8::system.bool
             79 
             80     [Function]
             81         Function Name    : main3
             82         Unique Name      : main::main3::#9
             83         Owner Unit       : main
             84         Level            : 0
             85         External Command : 
             86         Instance         : main::main3::#9::system.bool
             87 
             88     [Function]
             89         Function Name    : main
             90         Unique Name      : main::main::#4
             91         Owner Unit       : main
             92         Level            : 0
             93         External Command : 
             94         Instance         : main::main::#4::(system.float -> (system.list system.char))
             95 
             96     [Slot Item]
             97         Unique Name      : main::chars::#7::(system.list system.char)
             98         Parent Slot      : <NULL>
             99         Owner Function   : main::chars::#7
            100 
            101     [Slot Item]
            102         Unique Name      : main::eq::#2::(system.int -> (system.int -> system.bool))
            103         Parent Slot      : <NULL>
            104         Owner Function   : main::eq::#2
            105             3 = system::iequ::$kernelfp::iequ::(system.int -> (system.int -> system.bool))
            106 
            107     [Slot Item]
            108         Unique Name      : main::eq::#3::(system.float -> (system.float -> system.bool))
            109         Parent Slot      : <NULL>
            110         Owner Function   : main::eq::#3
            111             4 = system::fequ::$kernelfp::fequ::(system.float -> (system.float -> system.bool))
            112 
            113     [Slot Item]
            114         Unique Name      : main::exists::#1::(system.float -> ((system.list system.float-> system.bool))
            115         Parent Slot      : <NULL>
            116         Owner Function   : main::exists::#1
            117             0 = sysutils::if::#9::(system.bool -> (system.bool -> (system.bool -> system.bool)))
            118             1 = main::eq::#3::(system.float -> (system.float -> system.bool))
            119             2 = main::exists::#1::(system.float -> ((system.list system.float-> system.bool))
            120 
            121     [Slot Item]
            122         Unique Name      : main::exists::#1::(system.int -> ((system.list system.int-> system.bool))
            123         Parent Slot      : <NULL>
            124         Owner Function   : main::exists::#1
            125             0 = sysutils::if::#9::(system.bool -> (system.bool -> (system.bool -> system.bool)))
            126             1 = main::eq::#2::(system.int -> (system.int -> system.bool))
            127             2 = main::exists::#1::(system.int -> ((system.list system.int-> system.bool))
            128 
            129     [Slot Item]
            130         Unique Name      : main::floats::#6::(system.list system.float)
            131         Parent Slot      : <NULL>
            132         Owner Function   : main::floats::#6
            133 
            134     [Slot Item]
            135         Unique Name      : main::ints::#5::(system.list system.int)
            136         Parent Slot      : <NULL>
            137         Owner Function   : main::ints::#5
            138 
            139     [Slot Item]
            140         Unique Name      : main::main2::#8::system.bool
            141         Parent Slot      : <NULL>
            142         Owner Function   : main::main2::#8
            143             7 = main::exists::#1::(system.int -> ((system.list system.int-> system.bool))
            144             8 = main::ints::#5::(system.list system.int)
            145 
            146     [Slot Item]
            147         Unique Name      : main::main3::#9::system.bool
            148         Parent Slot      : <NULL>
            149         Owner Function   : main::main3::#9
            150             9 = main::exists::#1::(system.float -> ((system.list system.float-> system.bool))
            151             10 = main::floats::#6::(system.list system.float)
            152 
            153     [Slot Item]
            154         Unique Name      : main::main::#4::(system.float -> (system.list system.char))
            155         Parent Slot      : <NULL>
            156         Owner Function   : main::main::#4
            157             5 = sysutils::if::#9::(system.bool -> ((system.list system.char-> ((system.list system.char-> (system.list system.char))))
            158             6 = system::flt::$kernelfp::flt::(system.float -> (system.float -> system.bool))
            posted on 2008-11-02 07:36 陳梓瀚(vczh) 閱讀(1520) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): 腳本技術(shù)
            中文字幕热久久久久久久| 国内精品久久久久久久久| 久久精品18| 久久国产成人午夜aⅴ影院| 爱做久久久久久| 久久99精品国产麻豆婷婷| 久久精品无码免费不卡| 久久无码精品一区二区三区| 欧美久久久久久精选9999| 亚洲欧美久久久久9999| 午夜精品久久久久久毛片| 奇米综合四色77777久久| 久久免费高清视频| 人妻少妇精品久久| 国产精品久久久久国产A级| 国产精品欧美久久久久天天影视 | 精品九九久久国内精品| 色综合久久最新中文字幕| 成人午夜精品久久久久久久小说 | 久久精品人人做人人妻人人玩| 无码专区久久综合久中文字幕| 久久99精品久久久久久hb无码| 色噜噜狠狠先锋影音久久| 久久久久噜噜噜亚洲熟女综合| 久久大香萑太香蕉av| 伊人色综合久久天天| 国产成人无码精品久久久性色 | 久久国产高清一区二区三区| 日韩欧美亚洲综合久久影院Ds| WWW婷婷AV久久久影片| 亚洲AV伊人久久青青草原| 亚洲成色999久久网站| 中文字幕乱码人妻无码久久| 久久精品国产WWW456C0M| 亚洲AV乱码久久精品蜜桃| 精品国产婷婷久久久| 欧美丰满熟妇BBB久久久| 久久大香萑太香蕉av| 久久噜噜久久久精品66| 久久www免费人成精品香蕉| 国产情侣久久久久aⅴ免费|