 
  		        briankung
Programming Elixir 1.6 exercise solutions - Lists and Recursion-5
The provided solutions have a few typos or errors, this one in particular tipped me over into submitting errata:
defmodule MyList do 
  def filter([], _fun), do: [] 
  def filter([ head | tail ], fun) do 
    if fun.(head) do 
      [ head, filter(tail, fun) ] 
    else 
      [ filter(tail, fun) ] 
    end 
  end
end
The else block will result in nested lists instead of a single list.
See my test of the function here:
iex(11)> require Integer
iex(12)> MyList.filter([1,2,3], &Integer.is_even/1)
[[2, [[]]]]
It should be:
# ...
    else 
      filter(tail, fun)
    end 
If exercise solutions are fair game, I’d be happy to submit more errata.
First Post!
Popular Pragmatic Bookshelf topics
                         
                      
                       
          
                page 37 
ANTLRInputStream input = new ANTLRInputStream(is); 
as of ANTLR 4 .8 should be: 
CharStream stream = CharStreams.fromStream(i...
              
            
            
          
              New
 
          
                Dear Sophie. 
I tried to do the “Authorization” exercise and have two questions: 
When trying to plug in an email-service, I found the ...
              
            
            
          
              New
 
          
                “The ProductLive.Index template calls a helper function, live_component/3, that in turn calls on the modal component. ” 
Excerpt From: Br...
              
            
            
          
              New
 
          
                I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
              
            
            
          
              New
 
          
                When I run the coverage example to report on missing lines, I get: 
pytest --cov=cards --report=term-missing ch7
ERROR: usage: pytest [op...
              
            
            
          
              New
 
          
                Hi all, 
currently I wonder how the Tailwind colours work (or don’t work). 
For example, in app/views/layouts/application.html.erb I have...
              
            
            
          
              New
 
          
                Hi, I’m working on the Chapter 8 of the book. 
After I add add the point_offset, I’m still able to see acne: 
  
In the image above, I re...
              
            
            
          
              New
 
          
                Book: Programming Phoenix LiveView, page 142 (157/378), file lib/pento_web/live/product_live/form_component.ex, in the function below: 
d...
              
            
            
          
              New
 
          
                When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
              
            
            
          
              New
 
          
                @parrt 
In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
              
            
            
          
              New
Other popular topics
                         
                      
                       
          
                Reading something? Working on something? Planning something? Changing jobs even!? 
If you’re up for sharing, please let us know what you’...
              
            
            
          
              New
 
          
                I’ve been really enjoying obsidian.md: 
 
It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
              
            
            
          
              New
 
          
                I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
              
            
            
          
              New
 
          
                Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: 
asdf install erlang 23.1.2
Configure failed.
checking ...
              
            
            
          
              New
 
          
                I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: 
The Ser...
              
            
            
          
              New
 
          
                This looks like a stunning keycap set :orange_heart: 
A LEGENDARY KEYBOARD LIVES ON
When you bought an Apple Macintosh computer in the e...
              
            
            
          
              New
 
          
                Think Again 50% Off Sale »
The theme of this sale is new perspectives on familiar topics. 
Enter coupon code ThinkAgain2021 at checkout t...
              
            
            
          
              New
 
          
                Author Spotlight 
Mike Riley 
@mriley 
This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
              
            
            
          
              New
 
          
                Get the comprehensive, insider information you need for Rails 8 with the new edition of this award-winning classic.
  
Sam Ruby @rubys
...
              
            
            
              
          
              New
 
          
                This is cool! 
DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON
We just witnessed something incredible: the largest open-s...
              
            
            
          
              New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /python
- /rails
- /js
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /flutter
- /vscode
- /ash
- /html
- /opensuse
- /centos
- /php
- /zig
- /deepseek
- /scala
- /lisp
- /textmate
- /sublime-text
- /react-native
- /nixos
- /debian
- /agda
- /kubuntu
- /arch-linux
- /django
- /revery
- /deno
- /ubuntu
- /spring
- /manjaro
- /nodejs
- /diversity
- /lua
- /julia
- /slackware
- /c
 
		         
    





