miércoles, 29 de octubre de 2014

LED is my new Hello World - Go Time

As I keep learning Go, I'm learning more commands...so...as usual...here's my take on LED Numbers...maybe not the best code ever...but it works -:)

LED.go
package main

import ( "fmt"
   "strconv" 
   "strings" )

func main() {
 fmt.Print("Enter a number: ")
 var num int
 var list []string
 var line1, line2, line3 string
 fmt.Scanf("%d", &num)
 numList := strings.Split(strconv.Itoa(num), "")
 romans := map[string]string {
  "0" : " _  ,| | ,|_| ",
  "1" : "  ,| ,| ",
  "2" : " _  , _| ,|_  ",
  "3" : "_  ,_| ,_| ",
  "4" : "    ,|_| ,  | ",
  "5" : " _  ,|_  , _| ",
  "6" : " _  ,|_  ,|_| ",
  "7" : "_   , |  , |  ",
  "8" : " _  ,|_| ,|_| ",
  "9" : " _  ,|_| , _| ",
 }
 for _, value := range numList {
  list = strings.Split(romans[value],",")
  line1 += list[0]
  line2 += list[1]
  line3 += list[2]
 }
 fmt.Println(line1)
 fmt.Println(line2)
 fmt.Println(line3)
}

Here are the screenshots...



Greetings,

Blag.
Development Culture.

Mi first post on Go

As Go is gaining some popularity...I decided to give it a try...and sure...the fact that Ken Thompson is one of the three main designers of the language helped as well -:P

In order to learn I'm reading the book An Introduction to Programming in Go so expect a book review soon...



Now...my first impression of Go is that is basically C/C++ without the makeup...meaning...take out some nasty and weird features and you have yourself the Go programming language...

Go is supposed to be compiled, concurrent, imperative and structured.

Anyway...C++ was one of the first languages I ever learned so learning Go feels like going back home for a while...

For sure...the best way to learn a new language is to code something...so again I start by building something simple like the Fibonacci number generator based on Haskell code from another post...

Fibonacci.go
package main

import ( "fmt"
   "strconv" )

func main() {
 fmt.Print("Enter a number: ")
 var num int
 fmt.Scanf("%d", &num)
 fmt.Print(fib(num, 0, 1))
}

func fib(num int, a int, b int) string{
 var result string
 if a > 0 && num > 1 {
  result += strconv.Itoa(a+b) + " " + fib(num-1, a+b, a)
 } else if a == 0 {
  result = strconv.Itoa(a) + " " + strconv.Itoa(b) + 
                             " " + strconv.Itoa(a+b) + 
                             " " + fib(num-1, a+b, b)
 }
 return result
}

When we run it...we're going to see this -:)



Greetings,

Blag.
Development Culture.

How to Design Programs - Book Review

I just finished reading How to Design Programs, a book meant for beginners that want to get into the wonderful world of programming...and for that they use Scheme and DrScheme (which is now called Racket).



Of course, they don't focus on Scheme but on the design principles of programming...which makes this one a really important book.

The book itself is pretty big...with 565 pages...

There's a lot of really nice examples ranging from really basic to somehow complex, so there's a good learning curve attached to it.

Using Scheme as a starting point for learning programming is in my opinion a really smart choice...the syntax might be kind of weird sometimes but the good thing is that there are not so many keywords so learning it it's not a hard task...



Even if you have experience in programming...this book is really helpful and it goes beyond the simple act of programming as it teaches you how to design, build and test your application...making it more robust and less error prone...

If you have the chance...read this book...you will not regret it -;)

Greetings,

Blag.
Development Culture.

lunes, 27 de octubre de 2014

LeapTV - Game System Review

I have always love LeapFrog so when I read that we're planning to release a brand new gaming console...I couldn't stop myself from pre-ordering it -;)

LeapTV is in my opinion...a mix between Education, Wii and XBox Kinnect...just enough to keep our little ones engaged, exercised, happy and practice their school skills...


The console comes with a control and a Kinnect like sensor...but no cartrige games...however...it includes a "Pet Play World" game when you register it online...it's a nice game where you need to pick a pet and take care of him/her -;)

Of course...I couldn't left my daughter with just one included game...so I bought a couple more -:)


Kart Racing Supercharged is a "Mario Kart" like game where the kids needs to solve some math questions in order to get better equipment for their cars...

Sports! includes nine games like Super Goallie, Skateboarding and Bowling...and here kids needs to use their addition, subtraction, patterns and shapes skills...


The un-boxing and setup was of course pretty easy and the controller is wireless...


This picture is from the "Pet Play World" game...


And here's the skateboarding game on Sports!


Kart Racing Supercharged is really nice too -;)


I can say...LeapFrog and LeapTV haven't disappoint me at all...this is a great gaming console for little kids and they will open their App Store soon...so the fun will never end -;)

Greetings,

Blag.
Development Culture.

jueves, 16 de octubre de 2014

Realm of Racket - Book Review

I just finished reading Realm of Racket a book about Racket -:)


The book has 316 pages...so it's a big book...

It starts with the basics of Rackets but very quickly jumps into creating games with Racket...which is something really cool...specially if you want to build games with Racket...

The book comes with some nice and funny comic strips telling us the story of Chad and how using Racket he manage to solve some interesting challenges...

One thing that I didn't like too much about the book...is that I believe that some games are too long and even complex which kind of defeat the purpose of being a beginners book...

Anyway...the book comes with a lot of useful information and will make you be right on track with your Racket learning -;)

You will learn about Recusion, Lambdas, Loops, GameUI and Networking...





Racket is a powerful but strange programming language...so this book will help you to get more comfortable...

If you want to learn Racket in a fun way and built some nice games in the process...then this book is for you -:)

Greetings,

Blag.
Development Culture.

miércoles, 15 de octubre de 2014

LED is my new Hello World - Racket Time

If you thought I was going to miss the change to build an LED Number Generator in Racket...you got it all wrong -;)

I have to admit...it wasn't easy...Racket is nice but weird...takes some time to get used to it...but when things work...they just work -;)

Here's the source code...

LED.rkt
#lang racket
(define (showLED num)
  (display(get_led(toList num num 0 1) 1 num)))

(define (toList num num_o start end)
  (cond [(number? num) (toList(number->string num) (number->string num_o) start end)]
        [(and (string? num) (> (string-length num_o) 1)) (append (cons(substring num start end) '())
                                                                (toList num (substring num_o 1 (string-length num_o)) 
                                                                        (add1 start)(add1 end)))]
        [(and (string? num) (= (string-length num_o) 1)) (append (cons(substring num_o 0 1) '()))]))

(define (get_led x n num)
  (cond [(> (length x) 0) (append (cons(make_led_digit (string->number(first x)) n) '()) (get_led(rest x) n num))]
        [(and (= (length x) 0) (< n 3)) (append '("\n") (get_led(toList num num 0 1) (add1 n) num) )]
        [(and (= (length x) 0) (>= n 3)) append '()]))

(define (make_led_digit a b)
  (cond [(and (= a 0)(= b 1)) " _  "]
        [(and (= a 0)(= b 2)) "| | "]
        [(and (= a 0)(= b 3)) "|_| "]
        [(and (= a 1)(= b 1)) "  "]
        [(and (= a 1)(= b 2)) "| "]
        [(and (= a 1)(= b 3)) "| "]
        [(and (= a 2)(= b 1)) " _  "]
        [(and (= a 2)(= b 2)) " _| "]
        [(and (= a 2)(= b 3)) "|_  "]
        [(and (= a 3)(= b 1)) "_  "]
        [(and (= a 3)(= b 2)) "_| "]
        [(and (= a 3)(= b 3)) "_| "]
        [(and (= a 4)(= b 1)) "    "]
        [(and (= a 4)(= b 2)) "|_| "]
        [(and (= a 4)(= b 3)) "  | "]
        [(and (= a 5)(= b 1)) " _  "]
        [(and (= a 5)(= b 2)) "|_  "]
        [(and (= a 5)(= b 3)) " _| "]        
        [(and (= a 6)(= b 1)) " _  "]
        [(and (= a 6)(= b 2)) "|_  "]
        [(and (= a 6)(= b 3)) "|_| "]
        [(and (= a 7)(= b 1)) "_   "]
        [(and (= a 7)(= b 2)) " |  "]
        [(and (= a 7)(= b 3)) " |  "]
        [(and (= a 8)(= b 1)) " _  "]
        [(and (= a 8)(= b 2)) "|_| "]
        [(and (= a 8)(= b 3)) "|_| "]
        [(and (= a 9)(= b 1)) " _  "]
        [(and (= a 9)(= b 2)) "|_| "]
        [(and (= a 9)(= b 3)) " _| "]))

Here's how it looks like when we run it...


Well...gotta keep learning...so...see you soon -;)

Greetings,

Blag.
Development Culture.

lunes, 13 de octubre de 2014

My first post on Racket

In my eternal quest for weird programming languages...I came out finding Racket...which is basically the new name of "PLT-Scheme"...from the Lisp family...


Racket can be installed on Windows, Mac and Linux...so it's pretty cool -:) And also comes with a nice IDE called DrRacket...


I gotta say...Racket is like nothing I have ever seen before...that's why I love it -:D

And here comes the most weird thing of all...Racket is...
  • Functional
  • Procedural
  • Modular
  • Object-Oriented
  • Logical
  • Reflective
  • Meta

Crazy, huh? Right now I'm reading an awesome book called "Realm of Racket"...


And after reading the first 61 pages (yep...no more) I was able to translate my Fibonacci Haskell app into Racket...so here goes the code...

Fibonacci.rkt
#lang racket
(define (showFib num)
  (fib num 0 1))

(define (fib num a b)
  ( cond [(and (> a 0) (> num 1)) (append (cons (+ a b) '()) (fib (sub1 num) (+ a b) a))]
         [(= a 0) (append (append (cons a (cons b '())) (cons (+ a b) '())) (fib(sub1 num)(+ a b) b))]
         [(= 1 num) (append '())]))


Now...if we run it...we're going to see this...


Cool, huh? Works just as expected -:) Couldn't be happier -;)

Greetings,

Blag.
Development Culture.

Robot Turtles - Game Review

Being a geek dad...I couldn't pass the opportunity to buy this game for my daughter -;)


Robot Turtles it's an awesome board game that aims to teach the fundamentals of  programming to little kids.

The game itself is simple...we have a board and place to place our turtle (the game is up to 4 players), we need to place a gem that the turtle needs to reach and here is the fun comes in...

We have cards that indicates the movements that the turtle needs to perform...move forward, move to the left or move to the right.

The kid needs to stack the cards in order to make the turtle move around the board and finally reach the gem in order to win the game.

That's the most basic and simple setup...more complex involves crates, ice blocks and even ice towers...the ice ones can be blasted with a special laser beam card, while the crate can be moved provided that there's enough space left so the crate can be set on a empty slot...

Once you get some movements that can be repeated...like...

Move forward 4 times, then turn left, move forward 4 times again...

The "Move forward 4 times" can be replace by a function card so in would end like...

Function Card, then turn left, Function card...

We also have some rock towers, that can't be blasted away or move, so the kids needs to go around it....


If something goes wrong...the kid can use a "bug" card to undo the last play and rebuild it...which in the end means...repeat the action with a new set of instructions...

The game itself is really nice...and once the kids get comfortable with the mechanics of the game, we can setup really complex scenarios where they need to think how to get the gem in the shortest time using the less possible cards...


I would say...what could be better to teach our young one the joy of programming by playing a nice board game at the same time?

If you got the chance...go ahead and but it...it's really lots of fun -:D

Greetings,

Blag.
Development Culture.