Search results

Jump to navigation Jump to search
  • f (1, x) r = x : r f (k, x) r = x : f (k-1, x) r
    2 KB (362 words) - 17:33, 13 June 2020
  • f x r a@(Just q) | x == q = r a f x r _ = x : r (Just x)
    3 KB (454 words) - 15:07, 2 October 2020
  • new = fmap (\r -> Cons (writeIORef r) (readIORef r)) . newIORef new = fmap (\r -> Cons (writeSTRef r) (readSTRef r)) . newSTRef
    2 KB (338 words) - 20:04, 13 May 2020
  • Or using the slightly more verbose (w.r.t. <hask>(&&&)</hask>) Applicative combinators: f x r (Just a@(i,q)) | x == q = r (Just (i+1,q))
    3 KB (470 words) - 03:45, 19 May 2021
  • Given a binary tree as the usual Prolog term t(X,L,R) (or nil). As a preparation for drawing the tree, a layout algorithm is req layoutAux x y (Branch a l r) = (Branch (a, (x',y)) l' r', x'')
    2 KB (337 words) - 03:41, 10 January 2017
  • hbaltree x h = [Branch x l r | l <- hbaltree x hl, r <- hbaltree x hr]
    1 KB (215 words) - 13:38, 25 December 2016
  • leaves' (Branch _ l r) xs = leaves' l $ leaves' r xs
    615 bytes (90 words) - 13:39, 25 December 2016
  • insert k v (IMap xs) = insert' $ viewl r (l,r) = split (>= Key k undefined) xs
    2 KB (315 words) - 15:19, 6 February 2021
  • diff_select' n xs = do r <- randomRIO (0,(length xs)-1) let remaining = take r xs ++ drop (r+1) xs
    2 KB (244 words) - 00:09, 7 April 2019
  • reverseTree (Branch x l r) = Branch x (reverseTree r) (reverseTree l)
    666 bytes (91 words) - 13:37, 25 December 2016
  • ...<code>Bool</code>, for instance. Then a function of type <code>(t -> r) -> r</code>, is like a box which takes a question about a value of type <code>t< newtype Cont r t = Cont ((t -> r) -> r)
    7 KB (1,253 words) - 23:34, 25 June 2021
  • cbalTree n = let (q, r) = (n - 1) `quotRem` 2 in [Branch 'x' left right | i <- [q .. q + r],
    4 KB (694 words) - 01:23, 7 June 2021
  • range l r = scanl (+) l (replicate (l - r) 1) range l r = scanl op l $ replicate diff 1
    1 KB (214 words) - 02:08, 5 April 2014
  • removeAt k (x:xs) = let (a, r) = removeAt (k - 1) xs in (a, x:r) removeAt n (x:xs) = (l, x:r)
    2 KB (340 words) - 11:56, 26 April 2016
  • where (l, t', r) = layoutAux x1 1 t layoutAux x y (Branch a l r) = (ll', Branch (a, (x,y)) l' r', rr')
    4 KB (637 words) - 03:42, 10 January 2017
  • ...internals' (Branch x l r) xs = (x :) $ internals' l $ internals' r xs
    717 bytes (98 words) - 13:39, 25 December 2016
  • ...this string representation, if the tree is given as usual (as nil or t(X,L,R) term). Then write a predicate which does this inverse; i.e. given the stri treeToString (Branch x l r) =
    2 KB (372 words) - 03:43, 10 January 2017
  • ...20). Below, I set up the array <hask>r</hask> for exactly that, with <hask>r!0</hask> forced to <hask>True</hask> to bootstrap the whole thing. buyable n = r!n
    6 KB (929 words) - 06:42, 21 November 2020
  • <br /><hask>u :: Empty -> r</hask> <br /><hask>u :: r -> ()</hask>
    7 KB (1,086 words) - 10:33, 9 March 2023
  • symmetric (Branch _ l r) = mirror l r
    1 KB (179 words) - 13:36, 25 December 2016

View (previous 20 | next 20) (20 | 50 | 100 | 250 | 500)