On Mon, Jul 7, 2014 at 9:58 PM, Luke Immes <[email protected]> wrote:

> OK, now I will use 'rem' vs. 'mod'
> Using trial division for determining range of primes, code below works,
> except for the ending message.
> Other 'clean' programs regarding lists have worked perfectly.
> Not sure what to make of the message.
> Any suggestions? Thanks.
> /*
> clean 497>./primes
> [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97Run
> time error, rule 'prmFilter' in module 'primes' does not match
> Execution: 0.00  Garbage collection: 0.00  Total: 0.00
> clean 497>
> */
> module primes
> import StdEnv, StdInt, StdList, StdClass
>
> prmFilter :: Int [Int] -> [Int]
> prmFilter prime [n:rst]
> | n rem prime == 0 = prmFilter prime rst /* use rem instead of mod */
> | otherwise  = [n:prmFilter prime rst]
>
> primes :: [Int] -> [Int]
> primes [prime:rst] = [prime:primes (prmFilter prime rst)]
>
> Start :: [Int]
> Start = primes [2..100]
>

It's just for the test ?
because you can use rem instead of mod, in your first first code ?

Best

Loic


>
>
> On Mon, Jul 7, 2014 at 3:04 PM, Loïc Maury <[email protected]> wrote:
>
>> Hello Luke and Community,
>>
>> same error, I'am on Windows 7 with clean ide.
>>
>> It seem, that mod is declared on StdOverloaded :
>>
>> // Additional functions for integer arithmetic:
>> instance mod Int // arg1 modulo arg2
>> instance rem Int // remainder after integer division
>> instance gcd Int // Greatest common divider
>>
>> There are another file StdInt, we have rem and gcd :
>> // Additional functions for integer arithmetic:
>>
>> instance rem Int
>> where
>> (rem) a b
>> = code inline {
>>  remI
>>   }
>>
>> instance gcd Int
>> where
>> gcd x y    = gcdnat (abs x) (abs y)
>>  where
>> gcdnat x 0 = x
>>     gcdnat x y = gcdnat y (x rem y)
>>
>> but it seem, unfortunately no mod ?
>>
>> Maybe a professional of clean can answer better than I do.
>>
>> Best
>>
>> Loic
>>
>>
>> On Mon, Jul 7, 2014 at 5:53 PM, Luke Immes <[email protected]> wrote:
>>
>>>  Documentation makes reference to required modules, but 'mod' is still
>>> not working.
>>>
>>> Any suggestions? Thanks.
>>>
>>>
>>> clean 496>cat mymod.icl
>>>
>>> module mymod
>>>
>>> import StdEnv, StdInt, StdClass
>>>
>>> Start :: [Int]
>>>
>>> Start = [x*x \\ x <- [1..10] | x mod 2 == 0]
>>>
>>> ---------
>>>
>>> clean 495>make mymod
>>>
>>> clm -h 20m mymod -o mymod
>>>
>>> Compiling mymod
>>>
>>> Overloading error [mymod.icl,4,c;4;14]: "mod" no instance available of
>>> type Int
>>>
>>> make: *** [mymod] Error 1
>>>
>>> _______________________________________________
>>> clean-list mailing list
>>> [email protected]
>>> http://mailman.science.ru.nl/mailman/listinfo/clean-list
>>>
>>>
>>
>
_______________________________________________
clean-list mailing list
[email protected]
http://mailman.science.ru.nl/mailman/listinfo/clean-list

Reply via email to