archive-org.com » ORG » I » IOKE.ORG

Total: 746

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Kind: DefaultBehavior
    return true if the receiver is less than or equal to the argument otherwise false show source method other result other result result 1 other should be overridden will result in an inconsistent ordering by always returning 1 except when comparing to itself and then it will return 0 show source method other if cell other kind Mixins Comparing 0 0 1 other return true if the receiver is equal

    Original URL path: https://ioke.org/dok/release/kinds/Mixins/Comparing.html (2016-02-13)
    Open archived version from archive


  • Kind: DefaultBehavior
    or nil if no such element exists if an argument is given it should be a number describing how many elements to get the return value will be a list in that case show source method howMany nil if howMany result list self each n if howMany 0 return result howMany result cell n return result self each n return cell n return nil Mixins Enumerable first should return nil for an empty collection show source set first should be nil should take an optional argument of how many to return show source set first 0 should set first 1 should set first 2 should should return the first element for a non empty collection show source set 42 first should 42 CustomEnumerable first should 3first should return the first n elements for a non empty collection show source set 42 first 0 should set 42 first 1 should 42 set 42 first 2 should 42 42 44 46 first 2 should 42 44 set 42 44 46 first 3 sort should 42 44 46 CustomEnumerable first 2 should 3first 1second first dict howMany takes one argument the argument should be a number describing how many elements to get the return value will be a dict show source method howMany result dict self each n if howMany 0 return result howMany if cell n mimics Pair result n key n value result cell n nil return result Mixins Enumerable first dict should take an argument of how many to return show source set first dict 0 should set first dict 1 should set first dict 2 should should return the first n elements for a non empty collection show source set 42 first dict 0 should set 42 first dict 1 should 42 nil set 42 first dict 2 should 42 nil 42 44 46 first dict 2 should 42 nil 44 nil set 42 44 46 first dict 3 should 42 nil 44 nil 46 nil foo 42 bar 66 first dict 0 should foo 42 bar 66 first dict 2 should foo 42 bar 66 foo 42 bar 66 first dict 3 should foo 42 bar 66 CustomEnumerable first dict 2 should 3first nil 1second nil first set howMany takes one argument the argument should be a number describing how many elements to get the return value will be a set show source method howMany result set self each n if howMany 0 return result howMany result cell n return result Mixins Enumerable first set should take an argument of how many to return show source set first set 0 should set set first set 1 should set set first set 2 should set should return the first n elements for a non empty collection show source set 42 first set 0 should set set 42 first set 1 should set 42 set 42 first set 2 should set 42 42 44 46 first set 2 should set 42 44 set 42 44 46 first set 3 should set 42 44 46 CustomEnumerable first set 2 should set 3first 1second flatMap expects to get the same kind of arguments as map and that each map operation returns a list these lists will then be folded into a single list show source macro call resendToMethod map fold Mixins Enumerable flatMap should return a correct flattened list show source 1 2 3 flatMap x x should 1 2 3 1 2 3 flatMap x x x 10 x 20 should 1 11 21 2 12 22 3 13 23 4 5 6 flatMap x x 20 x 10 x should 24 14 4 25 15 5 26 16 6 flatMap dict expects to get the same kind of arguments as map dict and that each map operation returns a dict for key these dicts will then be folded into a single dict show source macro call resendToMethod map dict fold sum arg arg key each val sum val key val value sum Mixins Enumerable flatMap dict should return a correct flattened dict show source 1 2 3 flatMap dict x dict x x 2 should dict 1 3 2 4 3 5 1 2 3 flatMap dict x dict x nil x 10 nil x 20 nil should dict 1 nil 11 nil 21 nil 2 nil 12 nil 22 nil 3 nil 13 nil 23 nil 4 5 6 flatMap dict x dict x 20 nil x 10 nil x nil should dict 24 nil 14 nil 4 nil 25 nil 15 nil 5 nil 26 nil 16 nil 6 nil flatMap list nil show source macro call resendToMethod map fold flatMap set expects to get the same kind of arguments as map set and that each map operation returns a set these sets will then be folded into a single set show source macro call resendToMethod map set fold Mixins Enumerable flatMap set should return a correct flattened set show source 1 2 3 flatMap set x set x should set 1 2 3 1 2 3 flatMap set x set x x 10 x 20 should set 1 11 21 2 12 22 3 13 23 4 5 6 flatMap set x set x 20 x 10 x should set 24 14 4 25 15 5 26 16 6 fold nil show source macro argCount call arguments length if argCount 1 theCode call arguments 0 theCode theCode deepCopy elementName genSym theCode last message elementName sum nil self each i n if i 0 sum cell n call ground cell elementName cell n sum theCode evaluateOn call ground cell sum return cell sum if argCount 2 argName call arguments 0 theCode call arguments 1 elementName argName name sum nil self each i n if i 0 sum cell n call ground cell elementName cell n sum theCode evaluateOn call ground cell sum return cell sum if argCount 3 sumArgName call arguments 0 argName call arguments 1 theCode call arguments 2 lexicalCode LexicalBlock createFrom list sumArgName argName theCode call ground sum nil self each i n if i 0 sum cell n sum lexicalCode call cell sum cell n return cell sum if argCount 4 sum call argAt 0 sumArgName call arguments 1 argName call arguments 2 theCode call arguments 3 lexicalCode LexicalBlock createFrom list sumArgName argName theCode call ground self each n sum lexicalCode call cell sum cell n return cell sum error Condition Error Invocation NoMatch message call message context call currentContext Mixins Enumerable fold should take one argument that is a message chain and apply that on the sum with the current arg as argument show source 1 2 3 fold should 6 1 2 3 fold 5 should 12 CustomEnumerable2 fold should 9 should take two arguments that is an argument name and a message chain and apply that on the sum show source 1 2 3 fold x x 2 should 11 1 2 3 fold x 5 x should 12 CustomEnumerable2 fold x x should 9 should take three arguments that is the sum name the argument name and code to apply show source 1 2 3 fold sum x sum x 2 should 11 1 2 3 fold sum x sum 5 x should 12 CustomEnumerable2 fold sum x sum x should 9 should take four arguments that is the initial value the sum name the argument name and code to apply show source 1 2 3 fold 13 sum x sum x 2 should 25 1 2 3 fold 1 sum x sum 5 x should 87 CustomEnumerable2 fold 100 sum x sum x should 25 grep takes one two or three arguments grep will first find any elements in the collection matching the first argument with if two or three arguments are given these will be used to transform the matching object and then add the transformed version instead of the original element to the result list the two argument version expects the second argument to be a message chain and the three argument version expects it to be something that can be turned into a lexical block show source macro argCount call arguments length cond argCount 1 matchingAgainst call argAt 0 result list self each n if matchingAgainst cell n result cell n result argCount 2 matchingAgainst call argAt 0 theCode call arguments 1 result list self each n if matchingAgainst cell n result theCode evaluateOn call ground cell n result argCount 3 matchingAgainst call argAt 0 argName call arguments 1 theCode call arguments 2 result list lexicalCode LexicalBlock createFrom list argName theCode call ground self each n if matchingAgainst cell n result lexicalCode call cell n result error Condition Error Invocation NoMatch message call message context call currentContext Mixins Enumerable grep should take one argument and return everything that matches with show source 1 2 3 4 5 6 7 8 9 grep 2 5 should 2 3 4 5 customObj Origin mimic customObj method other other 3 other 5 1 2 3 4 5 6 7 8 9 grep customObj should 1 2 6 7 8 9 should take two arguments where the second argument is a message chain and return the result of calling that chain on everything that matches with show source 1 2 3 4 5 6 7 8 9 grep 2 5 1 should 3 4 5 6 customObj Origin mimic customObj method other other 3 other 5 1 2 3 4 5 6 7 8 9 grep customObj 1 should 2 3 7 8 9 10 should take three arguments where the second and third arguments gets turned into a lexical block to apply to all that matches with show source 1 2 3 4 5 6 7 8 9 grep 2 5 x x 1 asText should 3 4 5 6 customObj Origin mimic customObj method other other 3 other 5 1 2 3 4 5 6 7 8 9 grep customObj x x 1 asText should 2 3 7 8 9 10 grep set takes one two or three arguments grep will first find any elements in the collection matching the first argument with if two or three arguments are given these will be used to transform the matching object and then add the transformed version instead of the original element to the result set the two argument version expects the second argument to be a message chain and the three argument version expects it to be something that can be turned into a lexical block show source macro argCount call arguments length cond argCount 1 matchingAgainst call argAt 0 result set self each n if matchingAgainst cell n result cell n result argCount 2 matchingAgainst call argAt 0 theCode call arguments 1 result set self each n if matchingAgainst cell n result theCode evaluateOn call ground cell n result argCount 3 matchingAgainst call argAt 0 argName call arguments 1 theCode call arguments 2 result set lexicalCode LexicalBlock createFrom list argName theCode call ground self each n if matchingAgainst cell n result lexicalCode call cell n result error Condition Error Invocation NoMatch message call message context call currentContext Mixins Enumerable grep set should take one argument and return everything that matches with show source 1 2 3 4 5 6 7 8 9 grep set 2 5 should set 2 3 4 5 customObj Origin mimic customObj method other other 3 other 5 1 2 3 4 5 6 7 8 9 grep set customObj should set 1 2 6 7 8 9 should take two arguments where the second argument is a message chain and return the result of calling that chain on everything that matches with show source 1 2 3 4 5 6 7 8 9 grep set 2 5 1 should set 3 4 5 6 customObj Origin mimic customObj method other other 3 other 5 1 2 3 4 5 6 7 8 9 grep set customObj 1 should set 2 3 7 8 9 10 should take three arguments where the second and third arguments gets turned into a lexical block to apply to all that matches with show source 1 2 3 4 5 6 7 8 9 grep set 2 5 x x 1 asText should set 3 4 5 6 customObj Origin mimic customObj method other other 3 other 5 1 2 3 4 5 6 7 8 9 grep set customObj x x 1 asText should set 2 3 7 8 9 10 group returns a dict where all the keys are distinct elements in the enumerable and each value is a list of all the values that are equivalent show source method groupBy Mixins Enumerable group should return an empty dict for an empty enumerable show source group should 1 1 group should set group should should return a dict with all distinct values as keys show source abc cde foo cde group keys should set abc cde foo should group all the same values into a list show source 1 2 3 2 3 3 5 5 5 5 5 group should 1 1 2 2 2 3 3 3 3 5 5 5 5 5 5 foo 42 bar 55 group should foo 42 foo 42 bar 55 bar 55 groupBy takes zero one or two arguments it will evaluate all the elements in the enumerable and return a dictionary where the keys will be the result of evaluating the arguments and the value will be a list of all the original values that match that key show source macro argCount call arguments length cond argCount 0 result dict self each n x cell n if result key cell x result cell x cell n result cell x list cell n result argCount 1 theCode call arguments 0 result dict self each n x theCode evaluateOn call ground cell n if result key cell x result cell x cell n result cell x list cell n result argCount 2 argName call arguments 0 theCode call arguments 1 result dict lexicalCode LexicalBlock createFrom list argName theCode call ground self each n x lexicalCode call cell n if result key cell x result cell x cell n result cell x list cell n result error Condition Error Invocation NoMatch message call message context call currentContext Mixins Enumerable groupBy should return an empty dict for an empty enumerable show source groupBy should 1 1 groupBy should set groupBy should should return a dict with all distinct values as keys show source abc cde foo cde groupBy keys should set abc cde foo should group all the same values into a list show source 1 2 3 2 3 3 5 5 5 5 5 groupBy should 1 1 2 2 2 3 3 3 3 5 5 5 5 5 5 foo 42 bar 55 groupBy should foo 42 foo 42 bar 55 bar 55 should take one argument that is a message chain the result of this will be the grouping factor and used as key show source 1 2 3 2 3 3 5 5 5 5 5 groupBy 1 should 0 1 1 2 2 2 3 3 3 4 5 5 5 5 5 1 2 3 2 3 3 5 5 5 5 5 groupBy asText should 1 1 2 2 2 3 3 3 3 5 5 5 5 5 5 should take two arguments that is an argument name and code the result of this will be the grouping factor and used as key show source 1 2 3 2 3 3 5 5 5 5 5 groupBy x x 1 should 0 1 1 2 2 2 3 3 3 4 5 5 5 5 5 1 2 3 2 3 3 5 5 5 5 5 groupBy x x asText should 1 1 2 2 2 3 3 3 3 5 5 5 5 5 5 1 2 3 2 3 3 5 5 5 5 5 groupBy x x 2 0 should true 2 2 false 1 3 3 3 5 5 5 5 5 include toFind takes one argument and returns true if this element is in the collection comparisons is done with show source method toFind self each n if toFind cell n return true return false Mixins Enumerable include should return true if the element is in the enumeration show source 1 2 3 include 2 should be true CustomEnumerable include 1second should be true should return false if the element is not in the enumeration show source 1 2 3 include 0 should be false CustomEnumerable include 2second should be false inject takes one two three or four arguments all versions need an initial sum code to execute a place to put the current sum in the code and a place to stick the current element of the enumerable if one argument it has to be a message chain this message chain will be applied on the current sum the element will be appended to the argument list of the last message send in the chain the initial sum is the first element and the code will be executed once less than the size of the enumerable due to this if two arguments given the first argument is the name of the variable to put the current element in and the message will still be sent to the sum and the initial sum works the same way as for one argument when three arguments are given the whole thing will be turned into a lexical closure where the first argument is the name of the sum variable the second argument is the name of the element variable and the last argument is the code when given four arguments the only difference is that the first argument will be evaluated as the initial sum show source macro argCount call arguments length if argCount 1 theCode call arguments 0 theCode theCode deepCopy elementName genSym theCode last message elementName sum nil self each i n if i 0 sum cell n call ground cell elementName cell n sum theCode evaluateOn call ground cell sum return cell sum if argCount 2 argName call arguments 0 theCode call arguments 1 elementName argName name sum nil self each i n if i 0 sum cell n call ground cell elementName cell n sum theCode evaluateOn call ground cell sum return cell sum if argCount 3 sumArgName call arguments 0 argName call arguments 1 theCode call arguments 2 lexicalCode LexicalBlock createFrom list sumArgName argName theCode call ground sum nil self each i n if i 0 sum cell n sum lexicalCode call cell sum cell n return cell sum if argCount 4 sum call argAt 0 sumArgName call arguments 1 argName call arguments 2 theCode call arguments 3 lexicalCode LexicalBlock createFrom list sumArgName argName theCode call ground self each n sum lexicalCode call cell sum cell n return cell sum error Condition Error Invocation NoMatch message call message context call currentContext Mixins Enumerable inject should take one argument that is a message chain and apply that on the sum with the current arg as argument show source 1 2 3 inject should 6 1 2 3 inject 5 should 12 CustomEnumerable2 inject should 9 should take two arguments that is an argument name and a message chain and apply that on the sum show source 1 2 3 inject x x 2 should 11 1 2 3 inject x 5 x should 12 CustomEnumerable2 inject x x should 9 should take three arguments that is the sum name the argument name and code to apply show source 1 2 3 inject sum x sum x 2 should 11 1 2 3 inject sum x sum 5 x should 12 CustomEnumerable2 inject sum x sum x should 9 should take four arguments that is the initial value the sum name the argument name and code to apply show source 1 2 3 inject 13 sum x sum x 2 should 25 1 2 3 inject 1 sum x sum 5 x should 87 CustomEnumerable2 inject 100 sum x sum x should 25 join separator returns a string created by converting each element of the array to text separated by an optional separator show source method separator result self each index n result n asText if index count 1 result separator result Mixins Enumerable join Mixins Enumerable join with no arguments should convert an empty list to an empty string show source join should set join should should convert a list with one element to it s equivalent as text show source tempestuous turmoil join should tempestuous turmoil 1 join should 1 set 1 join should 1 should convert a list with multiple elements to a flat string of all its elements as text show source a man walked into a bar join should amanwalkedintoabar 1 2 3 4 5 join should 12345 Mixins Enumerable join with one argument should convert an empty list to an empty string show source join glue should set join glue should should convert a list with one element to it s equivalent as text show source tempestuous turmoil join glue should tempestuous turmoil set tempestuous turmoil join glue should tempestuous turmoil 1 join glue should 1 set 1 join glue should 1 should convert a list with multiple elements to a flat string of all its elements as text show source a man walked into a bar join should a man walked into a bar 1 2 3 4 5 join should 1 2 3 4 5 set 1 2 3 join split sort should 1 2 3 map takes one or two arguments if one argument is given it will be evaluated as a message chain on each element in the enumerable and then the result will be collected in a new List if two arguments are given the first one should be an unevaluated argument name which will be bound inside the scope of executing the second piece of code it s important to notice that the one argument form will establish no context while the two argument form establishes a new lexical closure show source macro argCount call arguments length if argCount 1 theCode call arguments 0 result list self each n x theCode evaluateOn call ground cell n result cell x result if argCount 2 argName call arguments 0 theCode call arguments 1 result list lexicalCode LexicalBlock createFrom list argName theCode call ground self each n x lexicalCode call cell n result cell x result error Condition Error Invocation NoMatch message call message context call currentContext Mixins Enumerable map should return an empty list for an empty enumerable show source map x x 2 should map x x 2 should set map x x 2 should should return the same list for something that only returns itself show source 1 2 3 map x x should 1 2 3 should take one argument and apply the inside show source 1 2 3 map 2 should 3 4 5 1 2 3 map 1 should 1 1 1 should take two arguments and apply the code with the argument name bound show source 1 2 3 map x x 3 should 4 5 6 1 2 3 map x 1 should 1 1 1 map dict takes one or two arguments if one argument is given it will be evaluated as a message chain on each element in the enumerable and then the result will be collected in a new Dict if the message chain returns a pair that pair will be used as key and value if it s something else that value will be the key and the value for it will be nil if two arguments are given the first one should be an unevaluated argument name which will be bound inside the scope of executing the second piece of code it s important to notice that the one argument form will establish no context while the two argument form establishes a new lexical closure show source macro argCount call arguments length cond argCount 1 theCode call arguments 0 result dict self each n x theCode evaluateOn call ground cell n if cell x kind Pair result x key x value result cell x nil result argCount 2 argName call arguments 0 theCode call arguments 1 result dict lexicalCode LexicalBlock createFrom list argName theCode call ground self each n x lexicalCode call cell n if cell x kind Pair result x key x value result cell x nil result error Condition Error Invocation NoMatch message call message context call currentContext Mixins Enumerable map dict should return an empty dict for an empty enumerable show source map dict x x 2 should dict map dict x x 2 should dict set map dict x x 2 should dict should return the same dict for something that only returns itself show source 1 2 3 map dict x x x should dict 1 1 2 2 3 3 should take one argument and apply the inside show source 1 2 3 map dict 2 should dict 1 2 2 2 3 2 1 2 3 map dict 1 1 should dict 1 1 should take two arguments and apply the code with the argument name bound show source 1 2 3 map dict x x x 3 should dict 1 4 2 5 3 6 1 2 3 map dict x x 1 should dict 1 1 2 1 3 1 1 2 3 map dict x x should dict 1 nil 2 nil 3 nil map list nil show source macro argCount call arguments length if argCount 1 theCode call arguments 0 result list self each n x theCode evaluateOn call ground cell n result cell x result if argCount 2 argName call arguments 0 theCode call arguments 1 result list lexicalCode LexicalBlock createFrom list argName theCode call ground self each n x lexicalCode call cell n result cell x result error Condition Error Invocation NoMatch message call message context call currentContext map set takes one or two arguments if one argument is given it will be evaluated as a message chain on each element in the enumerable and then the result will be collected in a new Set if two arguments are given the first one should be an unevaluated argument name which will be bound inside the scope of executing the second piece of code it s important to notice that the one argument form will establish no context while the two argument form establishes a new lexical closure show source macro argCount call arguments length cond argCount 1 theCode call arguments 0 result set self each n x theCode evaluateOn call ground cell n result cell x result argCount 2 argName call arguments 0 theCode call arguments 1 result set lexicalCode LexicalBlock createFrom list argName theCode call ground self each n x lexicalCode call cell n result cell x result error Condition Error Invocation NoMatch message call message context call currentContext Mixins Enumerable map set should return an empty set for an empty enumerable show source map set x x 2 should set map set x x 2 should set set map set x x 2 should set should return the same set for something that only returns itself show source 1 2 3 map set x x should set 1 2 3 should take one argument and apply the inside show source 1 2 3 map set 2 should set 3 4 5 1 2 3 map set 1 should set 1 should take two arguments and apply the code with the argument name bound show source 1 2 3 map set x x 3 should set 4 5 6 1 2 3 map set x 1 should set 1 mapFn blocks takes zero or more arguments that evaluates to lexical blocks these blocks should all take one argument these blocks will be chained together and applied on each element in the receiver the final result will be collected into a list the evaluation happens left to right meaning the first method invoked will be the first argument show source method blocks result list self each n current cell n blocks each b current cell b call cell current result current result Mixins Enumerable mapFn should take zero arguments and just return the elements in a list show source 1 2 3 mapFn should 1 2 3 CustomEnumerable mapFn should 3first 1second 2third should take one lexical block argument and apply that to each element and return the result in a list show source x fn arg arg 2 1 2 3 mapFn x should 3 4 5 x fn arg arg 0 2 CustomEnumerable mapFn x should 3fi 1se 2th should take several lexical blocks and chain them together show source x fn arg arg 2 x2 fn arg arg 2 1 2 3 mapFn x x2 should 6 8 10 x fn arg arg 0 2 x2 fn arg arg flurg CustomEnumerable mapFn x x2 should 3fiflurg 1seflurg 2thflurg mapFn dict blocks takes zero or more arguments that evaluates to lexical blocks these blocks should all take one argument these blocks will be chained together and applied on each element in the receiver the final result will be collected into a dict the evaluation happens left to right meaning the first method invoked will be the first argument show source method blocks result dict self each n current cell n blocks each b current cell b call cell current if cell current mimics Pair result current key current value result cell current nil result Mixins Enumerable mapFn dict should take zero arguments and just return the elements in a dict show source 1 2 3 mapFn dict should 1 nil 2 nil 3 nil CustomEnumerable mapFn dict should 3first nil 1second nil 2third nil should take one lexical block argument and apply that to each element and return the result in a dict show source x fn arg arg arg 2 1 2 3 mapFn dict x should 1 3 2 4 3 5 x fn arg arg 0 2 arg 0 0 CustomEnumerable mapFn dict x should 3fi 3 1se 1 2th 2 should take several lexical blocks and chain them together show source x fn arg arg arg 2 x2 fn arg arg value arg key 1 2 3 mapFn dict x x2 should 3 1 4 2 5 3 x fn arg arg 0 2 x2 fn arg arg flurg CustomEnumerable mapFn dict x x2 should 3fi flurg 1se flurg 2th flurg mapFn set blocks takes zero or more arguments that evaluates to lexical blocks these blocks should all take one argument these blocks will be chained together and applied on each element in the receiver the final result will be collected into a set the evaluation happens left to right meaning the first method invoked will be the first argument show source method blocks result set self each n current cell n blocks each b current cell b call cell current result current result Mixins Enumerable mapFn set should take zero arguments and just return the elements in a set show source 1 2 3 mapFn set should set 1 2 3 CustomEnumerable mapFn set should set 3first 1second 2third should take one lexical block argument and apply that to each element and return the result in a set show source x fn arg arg 2 1 2 3 mapFn set x should set 3 4 5 x fn arg arg 0 2 CustomEnumerable mapFn set x should set 3fi 1se 2th should take several lexical blocks and chain them together show source x fn arg arg 2 x2 fn arg arg 2 1 2 3 mapFn set x x2 should set 6 8 10 x fn arg arg 0 2 x2 fn arg arg flurg CustomEnumerable mapFn set x x2 should set 3fiflurg 1seflurg 2thflurg max takes zero one or two arguments if zero arguments returns the maximum elemnt ackording to the ordering if one argument expects it to be a message chain if that message chain that will be used as a transform to create the element to compare with finally if two arguments are given the first argument is an unevaluated name and the second is a code element these will together be turned into a lexical block and used as the transformer for comparison the result will always be an element from the collection or nil if the collection is empty show source macro argCount call arguments length cond argCount 0 theMax nil theMaxVal nil self each n x cell n if theMax nil theMax cell n theMaxVal cell x if theMaxVal cell x theMax cell n theMaxVal cell x theMax argCount 1 theCode call arguments 0 theMax nil theMaxVal nil self each n x theCode evaluateOn call ground cell n if theMax nil theMax cell n theMaxVal cell x if theMaxVal cell x theMax cell n theMaxVal cell x theMax argCount 2 argName call arguments 0 theCode call arguments 1 theMax nil theMaxVal nil lexicalCode LexicalBlock createFrom list argName theCode call ground self each n x lexicalCode call cell n if theMax nil theMax cell n theMaxVal cell x if theMaxVal cell x theMax cell n theMaxVal cell x theMax error Condition Error Invocation NoMatch message call message context call currentContext Mixins Enumerable max should return the maximum using the operator if no arguments are given show source 1 2 3 4 max should 4 set 5 6 7 153 1 max should 153 a b c max should c should accept a message chain and use that to create the comparison criteria show source 1 2 3 4 max 1 should 1 set 5 6 7 153 1 max 1 should 1 abc bfooo cc max length should bfooo should accept a variable name and code and use that to create the comparison criteria show source 1 2 3 4 max x 10 x should 1 set 5 6 7 153 1 max x if x 100 x x should 7 abc bfooo cc max x x 1 should bfooo member toFind nil show source method toFind self each n if toFind cell n return true return false Mixins Enumerable member should return true if the element is in the enumeration show source 1 2 3 member 2 should be true CustomEnumerable member 1second should be true should return false if the element is not in the enumeration show source 1 2 3 member 0 should be false CustomEnumerable member 2second should be false min takes zero one or two arguments if zero arguments returns the minimum elemnt ackording to the ordering if one argument expects it to be a message chain if that message chain that will be used as a transform to create the element to compare with finally if two arguments are given the first argument is an unevaluated name and the second is a code element these will together be turned into a lexical block and used as the transformer for comparison the result will always be an element from the collection or nil if the collection is empty show source macro argCount call arguments length cond argCount 0 theMin nil theMinVal nil self each n x cell n if theMin nil theMin cell n theMinVal cell x if theMinVal cell x theMin cell n theMinVal cell x theMin argCount 1 theCode call arguments 0 theMin nil theMinVal nil self each n x theCode evaluateOn call ground cell n if theMin nil theMin cell n theMinVal cell x if theMinVal cell x theMin cell n theMinVal cell x theMin argCount 2 argName call arguments 0 theCode call arguments 1 theMin nil theMinVal nil lexicalCode LexicalBlock createFrom list argName theCode call ground self each n x lexicalCode call cell n if theMin nil theMin cell n theMinVal cell x if theMinVal cell x theMin cell n theMinVal cell x theMin error Condition Error Invocation NoMatch

    Original URL path: https://ioke.org/dok/release/kinds/Mixins/Enumerable.html (2016-02-13)
    Open archived version from archive

  • Kind: DefaultBehavior
    index error Condition Error Invocation NoMatch message call message context call currentContext Mixins Sequenced each should be implemented in terms of seq show source x Origin mimic x mimic Mixins Sequenced seqObj SequenceHelper mimic seqObj mock next andReturn false x mock seq andReturn seqObj x each 42 should be possible to call with one message chain that will be applied to all arguments show source Ground y Ground xs method y self SequenceTester each xs y should 1 2 3 4 5 6 7 8 x 0 SequenceTester each nil x x should 8 should be possible to call with one argument name and code that will be applied to all arguments show source y SequenceTester each x y x y should 1 2 3 4 5 6 7 8 should be possible to call with two argument names and code that will be applied to all arguments show source y SequenceTester each i x y i x y should 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 should return the object show source SequenceTester each x x should be SequenceTester should establish a lexical context when invoking the methods this context will be the same for all invocations show source SequenceTester each x list blarg 32 cell x list should be false cell blarg should be false x 14 SequenceTester each x blarg 32 x should 14 should return a Sequence if called with no arguments show source x Origin mimic x mimic Mixins Sequenced seqObj SequenceHelper mimic x mock seq andReturn seqObj x each should be same seqObj filtered nil show source macro call resendToReceiver self seq Mixins Sequenced filtered should resend the call with all arguments to the result of calling seq show source x Origin mimic x mimic Mixins Sequenced seqObj SequenceHelper mimic x mock seq andReturn seqObj x filtered foo bar x 43 should 42 seqObj called should be true seqObj callInfo arguments should foo bar x 43 grepped nil show source macro call resendToReceiver self seq Mixins Sequenced grepped should resend the call with all arguments to the result of calling seq show source x Origin mimic x mimic Mixins Sequenced seqObj SequenceHelper mimic x mock seq andReturn seqObj x grepped foo bar x 43 should 42 seqObj called should be true seqObj callInfo arguments should foo bar x 43 indexed nil show source macro call resendToReceiver self seq interleave nil show source macro call resendToReceiver self seq Mixins Sequenced interleave should create a new sequence show source 1 2 3 interleave 1 5 should mimic Sequence should take an enumerable show source 1 2 3 interleave 5 15 asList should 1 5 2 6 3 7 should take a seq show source 1 2 3 interleave 5 15 seq asList should 1 5 2 6 3 7 should only take as many elements as needed from the self show source 1 2 3 4 5 6 interleave 10 11 asList should 1 10 2 11

    Original URL path: https://ioke.org/dok/release/kinds/Mixins/Sequenced.html (2016-02-13)
    Open archived version from archive

  • Kind: DefaultBehavior
    that represents a primitive implemented in Java Mimics Method Inactive cells kind Active cells argumentsCode arity keywords Specs Inactive cells details kind NativeMethod Active cells details argumentsCode returns the code for the argument definition arity nil show source method Arity

    Original URL path: https://ioke.org/dok/release/kinds/NativeMethod.html (2016-02-13)
    Open archived version from archive

  • Kind: DefaultBehavior
    kind Number Integer Number Ratio should have the correct kind show source Number Ratio kind should Number Ratio should mimic Rational show source Number Ratio should mimic Number Rational Number Rational should have the correct kind show source Number Rational should have kind Number Rational should mimic Number Real show source Number Rational should mimic Number Real Number Real should have the correct kind show source Number Real should have kind Number Real should mimic Number show source Number Real should mimic Number Number inspect should return the textual representation of the number show source 0 inspect should 0 22342340 inspect should 22342340 333391244 inspect should 333391244 should return the textual representation of a negative number show source 1 inspect should 1 22342340 inspect should 22342340 333391244 inspect should 333391244 Number notice should return the textual representation of the number show source 0 notice should 0 22342340 notice should 22342340 333391244 notice should 333391244 should return the textual representation of a negative number show source 1 notice should 1 22342340 notice should 22342340 333391244 notice should 333391244 Inactive cells details kind Number Active cells details other compares this against the argument should be overridden in this case only used to check for equivalent number kinds other nil show source method other if self same 0 Reflector other mimics cell other 0 bind rescue Condition Error fn c false self other Number should check for mimicness if receiver is Number show source Number should Number Number should Number Rational Number should Number Decimal Number should 123 Number should 123 3 Number should 1 3 Number should not Ground Number should not Origin abs Returns the absolute value of this number show source method if self 0 negation self Number abs should return zero for zero show source 0 abs should 0

    Original URL path: https://ioke.org/dok/release/kinds/Number.html (2016-02-13)
    Open archived version from archive

  • Kind: DefaultBehavior
    0 should 1 0 10 0 5 0 should 5 0 234 0 30 0 should 204 0 30 0 35 0 should 5 0 should return the difference between negative numbers show source 1 0 1 0 should 2 0 1 0 5 0 should 6 0 1 0 5 0 should 4 0 10 0 5 0 should 15 0 10 0 0 0 5 0 should 5 0 2545345345346547456756 0 2545345345346547456755 0 should 1 0 should return the number when 0 is the argument show source 1 0 0 0 should 1 0 10 0 0 0 should 10 0 1325234534634564564576367 0 0 0 should 1325234534634564564576367 0 should convert its argument to a decimal if its not a decimal show source 1 6 1 should 0 6 3 2 2 should 1 2 should convert its argument to a decimal with asDecimal if its not a decimal and not a rational show source x Origin mimic x asDecimal method 42 0 43 4 x should 1 4 should signal a condition if it isn t a number and can t be converted show source fn 1 Origin mimic should signal Condition Error Type IncorrectType should validate type of receiver show source Number Decimal should checkReceiverTypeOn 2 divisor returns the quotient of this number and the argument Number Decimal should cause a condition when dividing with 0 0 show source fn 10 0 0 0 should signal Condition Error Arithmetic DivisionByZero should divide simple numbers show source 2 0 1 0 should 2 0 4 2 2 0 should 2 1 200 0 5 0 should 40 0 should divide negative numbers correctly show source 8200 0 10 0 should 820 0 should divide with a negative dividend correctly show source 8200 0 10 0 should 820 0 should correctly handle a number that would generate an infinite expansion by being inexact show source 2 0 3 0 should 0 6666666666666666666666666666666667 should divide a negative number with a negative dividend show source 8200 0 10 0 should 820 0 should convert its argument to a decimal if its not a decimal show source 0 5 5 should 0 1 3 4 2 should 1 7 should convert its argument to a decimal with asDecimal if its not a decimal and not a rational show source x Origin mimic x asDecimal method 2 0 42 8 x should 21 4 should signal a condition if it isn t a decimal and can t be converted show source fn 1 0 Origin mimic should signal Condition Error Type IncorrectType should validate type of receiver show source Number Decimal should checkReceiverTypeOn 2 other compares this number against the argument returning 1 0 or 1 based on which one is larger if the argument is a rational it will be converted into a form suitable for comparing against a decimal and then compared if the argument is neither a Rational nor a Decimal it tries to call asDecimal and if that doesn

    Original URL path: https://ioke.org/dok/release/kinds/Number/Decimal.html (2016-02-13)
    Open archived version from archive

  • Kind: DefaultBehavior
    should not 42 should be inequal to a decimal show source Number Infinity should not 3 3 Number Infinity should be greater than well everything show source Number Infinity 31489014839014839014893014839018439184903184390184310943104391048390184309 should be true Inactive cells details kind Number Infinity Active cells details inspect Returns a text inspection of the object Number Infinity inspect should validate type of receiver show source Number Infinity should checkReceiverTypeOn inspect x Origin mimic x cell

    Original URL path: https://ioke.org/dok/release/kinds/Number/Infinity.html (2016-02-13)
    Open archived version from archive

  • Kind: DefaultBehavior
    Condition Error Type IncorrectType should validate type of receiver show source Number Integer should checkReceiverTypeOn 4 other returns this number right shifted by the argument Number Integer returns self shifted the given amount of bits to the right show source 7 1 should 3 4095 3 should 511 9245278 1 should 4622639 performs a left shift if given a negative value show source 7 1 should 7 1 4095 3 should 4095 3 performs a right shift if given a negative value as receiver show source 7 1 should 4 4095 3 should 512 should convert its argument to a number if its not a number or a decimal show source x Origin mimic x asRational method 1 7 x should 3 should signal a condition if it isn t a number and can t be converted show source fn 1 Origin mimic should signal Condition Error Type IncorrectType should validate type of receiver show source Number Integer should checkReceiverTypeOn 4 other returns this number bitwise xor the argument Number Integer should xor zeroes show source 0 0 should 0 should xor regular numbers show source 1 0 should 1 1 1 should 0 0 1 should 1 3 5 should 6 2 255 should 255 should xor large numbers show source 1 2 64 should 18446744073709551617 should convert its argument to a number if its not a number or a decimal show source x Origin mimic x asRational method 3 10 x should 9 should signal a condition if it isn t a number and can t be converted show source fn 1 Origin mimic should signal Condition Error Type IncorrectType should validate type of receiver show source Number Integer should checkReceiverTypeOn 4 even Returns true if this number is even false otherwise show source method 2 0 Number Integer even should return true if the number is even show source 4 even should true 0 even should true 2 even should true 10 even should true 1000000000000 even should true should return false if the number is not even show source 1 even should false 5 even should false 1 even should false 1999999999999 even should false odd Returns true if this number is odd false otherwise show source method 2 0 Number Integer odd should return false if the number is not odd show source 4 odd should false 0 odd should false 2 odd should false 10 odd should false 1000000000000 odd should false should return true if the number is odd show source 1 odd should true 5 odd should true 1 odd should true 1999999999999 odd should true pred Returns the predecessor of this number Number Integer pred should return the predecessor of 0 show source 0 pred should 1 should return the predecessor of a small positive number show source 1 pred should 0 2 pred should 1 12 pred should 11 41 pred should 40 99 pred should 98 should return the predecessor of a large positive number show source 465467257434567 pred

    Original URL path: https://ioke.org/dok/release/kinds/Number/Integer.html (2016-02-13)
    Open archived version from archive



  •