Skip to main content
added 119 characters in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99

Haskell, many previous byte counts 130 127 * 0.9 = 117114.3 bytes

f#(a:b)=f a:f#b;f#x=x
(f&x)1=f x;0=x;(f&x)i=f$f&x$i-1
i=id
r x=i%(1,x)
(g?x)[]=x;(g?x)(a:b)=g(g?x$b)aa;(g?x)y=x
f%(a,b)|a>b=[]|1<2=f a:f%(a+1,b)
f # (a:b) = f a : f#b        -- map on a list (a->head, b->tail) is f a in front of mapping f to b
f # x     = x                -- map on the empty list is the empty list
                             -- (non empty lists are caught in the line before) 

(f & x) 10 = f x                -- nesting onezero timetimes is f x
(f & x) i = f $ f&x $ i-1    -- nesting i times is f (nesting one time less)

i=id                         -- apply is just in Haskell is just the identity function 

r x = i % (1,x)              -- defined via the "table" of the identity function from 1 to x
 
(g ? x) []    = x            -- folding the empty list is x
(g ? x) (a:b) = g (g?x$b) a  -- folding g into a list (a->head, b->tail) is g applied to (folding g into b) and a
(g ? x) y     = x             -- folding the empty list is x
                             --  again, y must be the empty list, else it would have been handled by the previous line

f % (a,b)                    
  |a>b       = []                -- if iMin is greater than iMax, the table is empty
  |otherwise = f a : f%(a+1,b)   --  otherwise f a in front of the table with iMin increased by one

Haskell, many previous byte counts 130 * 0.9 = 117 bytes

f#(a:b)=f a:f#b;f#x=x
(f&x)1=f x;(f&x)i=f$f&x$i-1
i=id
r x=i%(1,x)
(g?x)[]=x;(g?x)(a:b)=g(g?x$b)a
f%(a,b)|a>b=[]|1<2=f a:f%(a+1,b)
f # (a:b) = f a : f#b        -- map on a list (a->head, b->tail) is f a in front of mapping f to b
f # x     = x                -- map on the empty list is the empty list
                             -- (non empty lists are caught in the line before) 

(f & x) 1 = f x              -- nesting one time is f x
(f & x) i = f $ f&x $ i-1    -- nesting i times is f (nesting one time less)

i=id                         -- apply is just in Haskell just the identity function 

r x = i % (1,x)              -- defined via the "table" of the identity function from 1 to x
 
(g ? x) []    = x            -- folding the empty list is x
(g ? x) (a:b) = g (g?x$b) a  -- folding g into a list (a->head, b->tail) is g applied to (folding g into b) and a

f % (a,b)                    
  |a>b       = []                -- if iMin is greater than iMax, the table is empty
  |otherwise = f a : f%(a+1,b)   --  otherwise f a in front of the table with iMin increased by one

Haskell, many previous byte counts 127 * 0.9 = 114.3 bytes

f#(a:b)=f a:f#b;f#x=x
(f&x)0=x;(f&x)i=f$f&x$i-1
i=id
r x=i%(1,x)
(g?x)(a:b)=g(g?x$b)a;(g?x)y=x
f%(a,b)|a>b=[]|1<2=f a:f%(a+1,b)
f # (a:b) = f a : f#b        -- map on a list (a->head, b->tail) is f a in front of mapping f to b
f # x     = x                -- map on the empty list is the empty list
                             -- (non empty lists are caught in the line before) 

(f & x) 0 = x                -- nesting zero times is x
(f & x) i = f $ f&x $ i-1    -- nesting i times is f (nesting one time less)

i=id                         -- apply in Haskell is just the identity function 

r x = i % (1,x)              -- defined via the "table" of the identity function from 1 to x

(g ? x) (a:b) = g (g?x$b) a  -- folding g into a list (a->head, b->tail) is g applied to (folding g into b) and a
(g ? x) y     = x             -- folding the empty list is x
                             --  again, y must be the empty list, else it would have been handled by the previous line

f % (a,b)                    
  |a>b       = []                -- if iMin is greater than iMax, the table is empty
  |otherwise = f a : f%(a+1,b)   --  otherwise f a in front of the table with iMin increased by one
added 86 characters in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99
f # [](a:b) = f a : f#b        -- map on a list (a->head, b->tail) is f a in front of mapping f to b
f # x     = []x                -- map on the empty list is the empty list
f # (a:b) = f a : f#b        -- map on a list (a->head, b        ->tail)- is(non fempty alists inare frontcaught ofin mappingthe fline tobefore) b

(f & x) 1 = f x              -- nesting one time is f x
(f & x) i = f $ f&x $ i-1    -- nesting i times is f (nesting one time less)

i=id                         -- apply is just in Haskell just the identity function 

r x = i % (1,x)              -- defined via the "table" of the identity function from 1 to x

(g ? x) []    = x            -- folding the empty list is x
(g ? x) (a:b) = g (g?x$b) a  -- folding g into a list (a->head, b->tail) is g applied to (folding g into b) and a

f % (a,b)                    
  |a>b       = []                -- if iMin is greater than iMax, the table is empty
  |otherwise = f a : f%(a+1,b)   --  otherwise f a in front of the table with iMin increased by one
f # []    = []               -- map on the empty list is the empty list
f # (a:b) = f a : f#b        -- map on a list (a->head, b->tail) is f a in front of mapping f to b

(f & x) 1 = f x              -- nesting one time is f x
(f & x) i = f $ f&x $ i-1    -- nesting i times is f (nesting one time less)

i=id                         -- apply is just in Haskell just the identity function 

r x = i % (1,x)              -- defined via the "table" of the identity function from 1 to x

(g ? x) []    = x            -- folding the empty list is x
(g ? x) (a:b) = g (g?x$b) a  -- folding g into a list (a->head, b->tail) is g applied to (folding g into b) and a

f % (a,b)                    
  |a>b       = []                -- if iMin is greater than iMax, the table is empty
  |otherwise = f a : f%(a+1,b)   --  otherwise f a in front of the table with iMin increased by one
f # (a:b) = f a : f#b        -- map on a list (a->head, b->tail) is f a in front of mapping f to b
f # x     = x                -- map on the empty list is the empty list
                             -- (non empty lists are caught in the line before) 

(f & x) 1 = f x              -- nesting one time is f x
(f & x) i = f $ f&x $ i-1    -- nesting i times is f (nesting one time less)

i=id                         -- apply is just in Haskell just the identity function 

r x = i % (1,x)              -- defined via the "table" of the identity function from 1 to x

(g ? x) []    = x            -- folding the empty list is x
(g ? x) (a:b) = g (g?x$b) a  -- folding g into a list (a->head, b->tail) is g applied to (folding g into b) and a

f % (a,b)                    
  |a>b       = []                -- if iMin is greater than iMax, the table is empty
  |otherwise = f a : f%(a+1,b)   --  otherwise f a in front of the table with iMin increased by one
added 105 characters in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99

Haskell, 157 * 0.9 = 141.3 153 * 0.9 = 137.7many previous byte counts 139 130 * 0.9 = 125.1117 bytes

f#[]=[];f#f#(a:b)=f a:f#bf#b;f#x=x
n f x (f&x)1=f x;n f x i=f$n f xx;(if&x)i=f$f&x$i-1)
i=id
r x=i%(1,x)
f (g x[]=x;f ?x)[]=x;(g ?x)(a:b)=g(f g x b?x$b)a
f%(a,b)|a>b=[]|1<2=f a:f%(a+1,b)

n& is nest: n ((*2) & 3) 4 -> 48

f? is fold: f ((+) ? 0) [1,2,3,4] -> 10

As requested an ungolfed version with comments. Note, & and ? are ternary infix operators, which require additional parentheses when called or pattern matched.

f # []    = []               -- map on the empty list is the empty list
f # (a:b) = f a : f#b        -- map on a list (a->head, b->tail) is f a in front of mapping f to b

n (f & x) 1 = f x                -- nesting one time is f x
n (f & x) i = f (n$ ff&x x$ (i-1))    -- nesting i times is f (nesting one time less)

i=id                         -- apply is just in Haskell just the identity function 

r x = i % (1,x)              -- defined via the "table" of the identity function from 1 to x

f (g ? x) [] = x    = x            -- folding the empty list is x
f (g ? x) (a:b) = g (f g x b?x$b) a  -- folding g into a list (a->head, b->tail) is g applied to (folding g into b) and a

f % (a,b)                    
  |a>b       = []                -- if iMin is greater than iMax, the table is empty
  |otherwise = f a : f%(a+1,b)   --  otherwise f a in front of the table with iMin increased by one

Thanks to @dfeuer and @Zgarb for some useful hints

Haskell, 157 * 0.9 = 141.3 153 * 0.9 = 137.7 139 * 0.9 = 125.1 bytes

f#[]=[];f#(a:b)=f a:f#b
n f x 1=f x;n f x i=f$n f x(i-1)
i=id
r x=i%(1,x)
f g x[]=x;f g x(a:b)=g(f g x b)a
f%(a,b)|a>b=[]|1<2=f a:f%(a+1,b)

n is nest: n (*2) 3 4 -> 48

f is fold: f (+) 0 [1,2,3,4] -> 10

As requested an ungolfed version with comments

f # []    = []               -- map on the empty list is the empty list
f # (a:b) = f a : f#b        -- map on a list (a->head, b->tail) is f a in front of mapping f to b

n f x 1 = f x                -- nesting one time is f x
n f x i = f (n f x (i-1))    -- nesting i times is f (nesting one time less)

i=id                         -- apply is just in Haskell just the identity function 

r x = i % (1,x)              -- defined via the "table" of the identity function from 1 to x

f g x [] = x                 -- folding the empty list is x
f g x (a:b) = g (f g x b) a  -- folding g into a list (a->head, b->tail) is g applied to (folding g into b) and a

f % (a,b)                    
  |a>b       = []                -- if iMin is greater than iMax, the table is empty
  |otherwise = f a : f%(a+1,b)   --  otherwise f a in front of the table with iMin increased by one

Thanks to @dfeuer for some useful hints

Haskell, many previous byte counts 130 * 0.9 = 117 bytes

f#(a:b)=f a:f#b;f#x=x
(f&x)1=f x;(f&x)i=f$f&x$i-1
i=id
r x=i%(1,x)
(g?x)[]=x;(g?x)(a:b)=g(g?x$b)a
f%(a,b)|a>b=[]|1<2=f a:f%(a+1,b)

& is nest: ((*2) & 3) 4 -> 48

? is fold: ((+) ? 0) [1,2,3,4] -> 10

As requested an ungolfed version with comments. Note, & and ? are ternary infix operators, which require additional parentheses when called or pattern matched.

f # []    = []               -- map on the empty list is the empty list
f # (a:b) = f a : f#b        -- map on a list (a->head, b->tail) is f a in front of mapping f to b

(f & x) 1 = f x              -- nesting one time is f x
(f & x) i = f $ f&x $ i-1    -- nesting i times is f (nesting one time less)

i=id                         -- apply is just in Haskell just the identity function 

r x = i % (1,x)              -- defined via the "table" of the identity function from 1 to x

(g ? x) []    = x            -- folding the empty list is x
(g ? x) (a:b) = g (g?x$b) a  -- folding g into a list (a->head, b->tail) is g applied to (folding g into b) and a

f % (a,b)                    
  |a>b       = []                -- if iMin is greater than iMax, the table is empty
  |otherwise = f a : f%(a+1,b)   --  otherwise f a in front of the table with iMin increased by one

Thanks to @dfeuer and @Zgarb for some useful hints

added 24 characters in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99
Loading
added 23 characters in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99
Loading
added 23 characters in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99
Loading
added 1028 characters in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99
Loading
added 1028 characters in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99
Loading
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99
Loading