scala learning ,some complex using sample